I have a MongoDB record as follow:
"id": 1,
"Tasks": [
{
"description": "BLAH",
"Tags": [
{
"Name": "test",
"tagID": "YRG+crq3SJucvlUwTo/uSg=="
},
{
"Name": "Cars",
"tagID": "ObwiiZpNTOGECgHb1HehHg=="
}
]
},
......
]
I'm trying to delete the object from 'Tags' with the 'Name: test' by reference to its 'tagID'. The query I have deletes the whole record within 'Tasks' not just that particular Tags object.
db.user.update({ 'id': 1 },
{
'$pull': { 'Tasks': {'Tags.tagID': "YRG+crq3SJucvlUwTo/uSg==" }}
},
{ '$multi': 'true' }
)
How can I ammend my query to only remove that particular tag and not remove the entire record?