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

locate mistake when using $ operation on arrays

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • ALL

      For Example:
      1,Create document which include two arrays that array "b" contain "name" attribute like "a"
      db.test.insert(
      {
      "a":[

      {"name":"a","age":"99"}

      ,

      {"name":"b","age":"99"}

      ],
      "b":[

      {"level":"a","name":"a","age":"99"}

      ,

      {"level":"b","name":"b","age":"99"}

      ]}
      )

      2,Update document which I want locate

      {"name":"a","age":"99"}

      in "a" and

      {"level":"b","name":"b","age":"99"}

      in "b"
      db.test.update(

      {"a.name":"a","b.level":"b"}

      ,
      {"$set":{"a.$.age":"100","b.$.age":"100"}}
      )

      But the result is:
      {"_id":ObjectId("53437c573de4c79e7ff69e91"),
      "a":[

      {"name":"a", "age":"99" }

      ,

      {"age":"100","name":"b"}

      ],
      "b":[

      {"level":"a","name":"a","age":"99"}

      ,

      {"age":"100","level":"b","name" :"b"}

      ]
      }
      Updated the "

      { "age" : "100", "name" : "b" }

      " in "a" like above ...

            Assignee:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Reporter:
            kimshen KimShen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: