-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
None
-
Affects Version/s: 2.2.0
-
Component/s: JavaScript, Write Ops
-
Environment:Linux
-
Linux
Here are the data before update
{ "_id" : ObjectId("506c614a80178fe821c091bf"), "identifier" : "1", "list" : [ { "identifier" : { "id" : "1", "type" : "raw" }, "name" : "name1" }, { "identifier" : { "id" : "2", "type" : "raw" }, "name" : "name2" } ] }
I try to update the second element
db.test.update({identifier:"1","list.identifier.id":"2","list.identifier.type":"raw"},{$set:{"list.$.name":"name22"}},false,true);
...but mongo updated the first
{ "_id" : ObjectId("506c614a80178fe821c091bf"), "identifier" : "1", "list" : [ { "identifier" : { "id" : "1", "type" : "raw" }, "name" : "name22" }, { "identifier" : { "id" : "2", "type" : "raw" }, "name" : "name2" } ] }
This time I give a different order for the request
db.test.update({identifier:"1","list.identifier.type":"raw","list.identifier.id":"2"},{$set:{"list.$.name":"name222"}},false,true);
...and mongo updated the correct element
{ "_id" : ObjectId("506c614a80178fe821c091bf"), "identifier" : "1", "list" : [ { "identifier" : { "id" : "1", "type" : "raw" }, "name" : "name22" }, { "identifier" : { "id" : "2", "type" : "raw" }, "name" : "name222" } ] }