Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
3.2.3
-
None
-
ALL
Description
Consider the following example:
db.getCollection("test").insert({ |
"_id" : 5, |
"scopes" : [ |
"a", |
"b" |
],
|
"tags" : [ |
{
|
"name" : "abc", |
"id" : 1 |
},
|
{
|
"name" : "def", |
"id" : 2 |
}
|
]
|
})
|
|
db.getCollection('test').update({ |
"_id" : 5, |
"scopes" : { "$in" : ["a"]}, |
"tags.id" : 2 |
}, {
|
"$set" : { "tags.$.name" : "ghi"} |
})
|
This example changes the first tag name abc to ghi instead of the desired behavior of changing the tag with name def to ghi.
I think the $in operator is setting the positional operator $, because if we change the query for "scopes" :
{ "$in" : ["b"]}, then the second tag is getting updated...