How can I remove all "aFHJBrKu54y5mWjY3" in "newFor"?
Trying do this, but it does not work.
Messages.update({
users: { $all: ["CnugxoBWs4ox6vG2k", "aFHJBrKu54y5mWjY3"] }
},
{
$pull: {
"messages.$.newFor": "aFHJBrKu54y5mWjY3"
}
},
{ multi: true }
);
{
"_id" : "gQnYi2e54zADwgipx",
"users" : [
"aFHJBrKu54y5mWjY3",
"CnugxoBWs4ox6vG2k"
],
"lastMessageAt" : ISODate("2020-06-22T22:50:35.579Z"),
"messages" : [
{
"id" : "4d2219d05645a3991d3aae89",
"addedAt" : ISODate("2020-06-22T22:50:35.579Z"),
"userId" : "CnugxoBWs4ox6vG2k",
"newFor" : [
"aFHJBrKu54y5mWjY3",
"CnugxoBWs4ox6vG2k"
],
"message" : "Test"
},
{
"id" : "b42641118bb080cb9122062f",
"addedAt" : ISODate("2020-06-22T22:48:24.359Z"),
"userId" : "aFHJBrKu54y5mWjY3",
"newFor" : [
"aFHJBrKu54y5mWjY3"
],
"message" : "Test 2"
},
{
"id" : "244e77bb8324dc0b0f0e2def",
"addedAt" : ISODate("2020-06-22T22:48:14.643Z"),
"userId" : "CnugxoBWs4ox6vG2k",
"newFor" : [
"aFHJBrKu54y5mWjY3"
],
"message" : "Test 3"
}
]
}