[SERVER-29101] how to use $elemMatch with $in operator in the match section of an update command Created: 06/May/17  Updated: 12/May/17  Resolved: 12/May/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.4.2
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: vikram pawar Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-1243 New operator to update all matching i... Closed
Participants:

 Description   

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" : 1, "admin" : true, "deleted_at" : null, "added_after" : null, "exited" : false, "removed" : false }

,

{ "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 }

]



 Comments   
Comment by Kelsey Schubert [ 12/May/17 ]

Hi vikrampawar92,

Thanks for describing your use case. The functionality that you're looking for is tracked in SERVER-1243. Please feel free to vote for SERVER-1243 and watch it for updates.

Kind regards,
Thomas

Generated at Thu Feb 08 04:19:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.