Piggybacking the updating of user tag list.
When a new task is being added to a challenge, added code to update user tag list along with the existing code that already involves syncing / updating the user documents of challenge members.
This commit is contained in:
@@ -235,7 +235,18 @@ async function _addTaskFn (challenge, tasks, memberId) {
|
||||
});
|
||||
|
||||
// Update the user
|
||||
toSave.unshift(User.update({ _id: memberId }, updateTasksOrderQ).exec());
|
||||
const addToChallengeTagSet = {
|
||||
$addToSet: {
|
||||
tags: {
|
||||
id: challenge._id,
|
||||
name: challenge.name,
|
||||
challenge: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
const updateUserParams = { ...updateTasksOrderQ, ...addToChallengeTagSet };
|
||||
toSave.unshift(User.update({ _id: memberId }, updateUserParams).exec());
|
||||
|
||||
return Promise.all(toSave);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user