You want to pullAll
Users.update(
{ "_id": 1 },
{ "$pullAll": {"users": [2], "scenarios": [ 11, 44, 55 ]} }
,
function(err, numAffected) {
}
);
Like that, should do it.
Domanda
Here is a an example document I have.
Users
{
"_id": 1,
"users": [2,3,4,5],
"scenarios": [11,22,44,55]
}
I'd like remove the elements 2 from users and 11 44 55 from scenarios. I was attemping to perform two $pull in a single update but I can't seem to get it to work with the following.
Users.update(
{ _id: 1},
{$pull: { users: 2 },
{scenarios : '11 44 55' },
function(err,numberaffected){}
);
Any help with the following query would be appreciated.
Soluzione
You want to pullAll
Users.update(
{ "_id": 1 },
{ "$pullAll": {"users": [2], "scenarios": [ 11, 44, 55 ]} }
,
function(err, numAffected) {
}
);
Like that, should do it.