mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Update move-deleted-classroom-members script
This commit is contained in:
parent
5884a7ce8d
commit
7415e61763
1 changed files with 14 additions and 13 deletions
|
@ -1,16 +1,17 @@
|
|||
var classrooms = db.classrooms.find();
|
||||
classrooms.forEach(function (classroom) {
|
||||
printjson(classroom.members);
|
||||
print('classroom', classroom._id);
|
||||
classroom.members.forEach(function (userID) {
|
||||
var user = db.users.findOne({ _id: userID }, { deleted: true });
|
||||
if (user.deleted) {
|
||||
db.classrooms.update(
|
||||
print('\tFOUND ONE', userID);
|
||||
print('\t', db.classrooms.update(
|
||||
{ _id: classroom._id },
|
||||
{
|
||||
$addToSet: { deletedMembers: userID },
|
||||
$pull: { members: userID },
|
||||
},
|
||||
);
|
||||
$pull: { members: userID }
|
||||
}
|
||||
));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue