I am having the following projects document:
{
"_id":"59f96bd3108265ce6904e0b6",
"posts":[
{
"id":"b37108dc-d27f-49fa-ab9d-4d4fd5c9484b",
"accounts":["59fe8725108265c739a08b67", "59fad4d9108265572001dd49"]
},
{
"id":"b37108dc-d27f-49fa-ab9d-4d4fd5c9484b",
"accounts":["59fe8725108265c739a08b67","59dae438cc0a312805e70ada"]
},
{
"id":"b37108dc-d27f-49fa-ab9d-4d4fd5c9484b",
"accounts":["59fe8725108265c739a08b67","59dae438cc0a312805e70ada"]
}
]
}
I want to pull/remove 59fe8725108265c739a08b67
from posts.$.accounts
. I tried following query.
db.projects.update(
{"_id" : "59f96bd3108265ce6904e0b6"},
{ "$pull": { "posts.$.accounts": {$in: ["59fe8725108265c739a08b67"]} } })
But somehow it's not working. It always returns me:
WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0, "writeError" : { "code" : 16837, "errmsg" : "The positional operator did not find the match needed from the query. Unexpanded update: posts.$.accounts" } })