I a mongo db collection called exampleCollection
.
Inside of the collection are documents.
The documents have a property called members
.
db.collection('exampleCollection).find({ 'members._id': 'memberId1' })
yeilds
[
{
"_id" : "exampleId1",
"members": [
{ "_id": "memberId1", "removed" : true },
{ "_id": "memberId2" }
]
},
{
"_id" : "exampleId2",
"members": [
{ "_id": "memberId1" },
{ "_id": "memberId", "removed" : true }
]
}
]
I am trying to formulate a query that would eliminate the members
marked as removed. Right now it seems as though the best that I can do is remove examples
with members which are marked as removed. I just want to eliminate the items in the nested members
arrays.
I'm wondering if this is possible. I suspect that I might have to split this document up into multiple collections but I would like to know if this is possible first.