I have a document
firm {
"_id" : 0,
"users" : [
{
"draft_items" : [
{
"pkg" : "10",
"id" : 1
},
{
"pkg" : "10",
"id" : 2
},
]
}
]
}
I want to pull the element from draft items where id
is 2
Here is the expected result:
{
"_id" : 0,
"users" : [
{
"draft_items" : [
{
"pkg" : "10",
"id" : 1
}
]
}
]
}
I followed this:MongoDB pull element from array two levels deep and tried
db.firm.update( { 'users.draft_items.id' : 2 },{ $pull: { "users.$.draft_items": {"id":2} } } )
But it did not work!