-
Type: Bug
-
Resolution: Duplicate
-
Priority: Critical - P2
-
None
-
Affects Version/s: 2.6.0
-
Component/s: Querying
-
None
-
ALL
We have this document
{ "_id" : ObjectId("539fe24d822ea86809480f0c"), "bbs" : [ { "_id" : ObjectId("539fe24d822ea86809480f06"), "name" : "pelanggan", "bbattributes" : [ { "_id" : ObjectId("539fe24d822ea86809480f07"), "name" : "nama", "cell" : "l-0", "status" : "active" }, { "_id" : ObjectId("539fe24d822ea86809480f08"), "name" : "dob" } ] }, { "_id" : ObjectId("539fe24d822ea86809480f09"), "name" : "nota", "bbattributes" : [ { "_id" : ObjectId("539fe24d822ea86809480f0a"), "name" : "tanggal", "cell" : "r-0", "status" : "active" }, { "_id" : ObjectId("539fe24d822ea86809480f0b"), "name" : "lunas" } ] } ] }
This update syntax is supposed to update bbattributes whose name is "dob", but instead it updates "nama".
db["apps"].update({"_id": ObjectId('539fe24d822ea86809480f0c'),"bbs._id": ObjectId('539fe24d822ea86809480f06'),"bbs.0.bbattributes._id": ObjectId('539fe24d822ea86809480f08')},{"$set": {"bbs.0.bbattributes.$.status": "active", "bbs.0.bbattributes.$.cell": "l-1"}});
Here is the result after update
{ "_id" : ObjectId("539fe24d822ea86809480f0c"), "bbs" : [ { "_id" : ObjectId("539fe24d822ea86809480f06"), "name" : "pelanggan", "bbattributes" : [ { "_id" : ObjectId("539fe24d822ea86809480f07"), "name" : "nama", "cell" : "l-1", "status" : "active" }, { "_id" : ObjectId("539fe24d822ea86809480f08"), "name" : "dob" } ] }, { "_id" : ObjectId("539fe24d822ea86809480f09"), "name" : "nota", "bbattributes" : [ { "_id" : ObjectId("539fe24d822ea86809480f0a"), "name" : "tanggal", "cell" : "r-0" }, { "_id" : ObjectId("539fe24d822ea86809480f0b"), "name" : "lunas" } ] } ] }
Why does it update the wrong index, which I suspect to be always the first element?
- duplicates
-
SERVER-831 Positional Operator Matching Nested Arrays
- Closed