feat: make assignedTo field accept multiple values for all collections
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user