Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29101

how to use $elemMatch with $in operator in the match section of an update command

    • Type: Icon: Question Question
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.2
    • Component/s: Querying
    • Labels:
      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" : 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 }

      ]

            Assignee:
            Unassigned Unassigned
            Reporter:
            vikrampawar92 vikram pawar
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: