| Steps To Reproduce: |
$ mongo ran_q_test
|
|
> db.users.update({"_id":ObjectId("54a251b862656e1dc1000000"),"contacts._id":ObjectId("54a251b862656e1dc1010000"),"contacts.0.contact_ranks._id": ObjectId("54a251b862656e1dc1030000")}, {"$set": {"contacts.0.contact_ranks.$.value": 200000}})
|
You will expect that contact_rank document with the id: 54a251b862656e1dc1030000 will have updated attribute "value", n'est ce pas?
But somehow you discover that the other document was updated with the id 54a251b862656e1dc1020000
My conclusion is that it updates the first element in sub collection.
> db.users.find()[0].contacts[0].contact_ranks
|
[
|
{
|
"_id" : ObjectId("54a251b862656e1dc1020000"),
|
"_type" : "ContactRank",
|
"name" : "sexy",
|
"value" : 200000
|
},
|
{
|
"_id" : ObjectId("54a251b862656e1dc1030000"),
|
"_type" : "ContactRank",
|
"name" : "cool"
|
},
|
{
|
"_id" : ObjectId("54a251b862656e1dc1040000"),
|
"_type" : "ContactRank",
|
"name" : "hot"
|
},
|
{
|
"_id" : ObjectId("54a251b862656e1dc1050000"),
|
"_type" : "ContactRank",
|
"name" : "smart"
|
},
|
{
|
"_id" : ObjectId("54a251b862656e1dc1060000"),
|
"_type" : "ContactRank",
|
"name" : "ugly"
|
},
|
{
|
"_id" : ObjectId("54a251b862656e1dc1070000"),
|
"_type" : "ContactRank",
|
"name" : "angry"
|
}
|
]
|
|