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

multiple object update in array field

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      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 } ] }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            mayanktyagi1992 Mayank Tyagi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: