feat: make assignedTo field accept multiple values for all collections

This commit is contained in:
2025-11-18 13:32:47 +05:30
parent b7f63479a6
commit 8f5c0a1827
12 changed files with 202 additions and 108 deletions

View File

@@ -46,7 +46,10 @@ export async function createNote(
if (!obj.taggedUsers) {
await model.updateOne(
{ pid: resourceId },
{ $set: { taggedUsers: taggedUsers, assignedTo: userIds[0] } }
{
$set: { taggedUsers: taggedUsers },
$addToSet: { assignedTo: userIds[0] },
}
);
} else {
for (const user of taggedUsers) {
@@ -57,7 +60,11 @@ export async function createNote(
else obj.taggedUsers.push(user);
}
obj.assignedTo = userIds[0];
const assignee = obj.assignedTo.find(
(item) => item.toString() == userIds[0]
);
if (!assignee) obj.assignedTo.push(userIds[0]);
obj.markModified("taggedUsers", "assignedTo");
await obj.save();