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

multiple object update in array field

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I have an object array in my document and i want to update them all but mongo update only the first one matching to the update condition

      for example I have a doc :

      { "_id" : ObjectId("590aee020a0556027b14b262"), "x" : [ { "y" : 1 }, { "y" : 1 }, { "y" : 1 }, { "y" : 1 } ] }
      

      Now I am updating this :-

      db.users.update({"x.y":1},{$set:{"x.$.y":2}},{multi:true})
      

      then only get the first object updated :-

      { "_id" : ObjectId("590aee020a0556027b14b262"), "x" : [ { "y" : 2 }, { "y" : 1 }, { "y" : 1 }, { "y" : 1 } ] }
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: