I wrote this query to delete the agentName and agentNumber from the array when a match is found. I don't know why its not working.
db.collection('departments').update({}, {$pull:{"agents" : {'agentNumber':xxxxx}}},function(err,result) {
console.log("Agent Deleted successfully")
console.log(err)
})
Here's the db:
{
"name": "xxx",
"departments": [
{
"departmentName": "Technical",
"agents": [
{
"agentName": "xxx",
"agentNumber": "xxx",
},
{
"agentName": "xxx",
"agentNumber": "xxxxx", // 5 x's
}
]
}
]
}