Given below data, I want to delete all sub-documents in "data" where "k" == "c". That's my code:
var query = Query.EQ("templateId", "537c6648d7d6bd0a68a34918");
var update = Update.Pull("data", new BsonDocument() { { "k", "c" } });
MyMongoCollection.Update(query, update);
So what happens is that exactly 1 document is affected and the updating stops. I verified the query and it returns all documents as expected. Just with the pull-update, it breaks.
What could be wrong?
WriteConcern has no error. The query alone returns 3 docs and the WriteConcern has 1 doc affected.
{
"_id" : ObjectId("537c85a2d7d6bd0a68a3491b"),
"templateId" : "537c6648d7d6bd0a68a34918",
"data" : [
{"k" : "b", "v" : "111"},
{"k" : "a", "v" : "222"},
{"k" : "c", "v" : "333"}
]
},
{
"_id" : ObjectId("537d6a41d7d6bd0608cb27a4"),
"templateId" : "537c6648d7d6bd0a68a34918",
"data" : [
{"k" : "b", "v" : "111"},
{"k" : "a", "v" : "222"},
{"k" : "c", "v" : "333"}
]
}