-
Type: Question
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.4.2
-
Component/s: Querying
-
None
how to use $elemMatch with $in operator in the match section of an update command....for reference check out the below command:
Db.collection.update({participants:{$elemMatch:{participant:{$in :[1,4,5]}}}}, {$set:{"participants.$.removed": true}})
Below is the document:
{
"_id" : ObjectId("590c24e76c8e0669334b68a5"),
"name" : "The Group Name 2",
"participants" : [
,
{ "participant" : 4, "admin" : false, "deleted_at" : null, "added_after" : null, "exited" : false, "removed" : false },
{ "participant" : 8, "admin" : false, "deleted_at" : null, "added_after" : null, "exited" : false, "removed" : false },
{ "participant" : 5, "admin" : false, "deleted_at" : null, "added_after" : null, "exited" : false, "removed" : false }]
- duplicates
-
SERVER-1243 New operator to update all matching items in an array
- Closed