i have the following document , it has two array's , one inside the other ,
attachment array and files array inside attachment array .
i want to delete an element inside files array using this element _id . but its not working with me , i tried this code , it return
{ n: 144, nModified: 0, ok: 1 }
Invoice.update({}, {
$pull: {
"attachment":
{
"files":
{
$elemMatch:
{ _id: ObjectId("5b7937014b2a961d082de9bf") }
}
}
}
}, { multi: true })
.then(result => {
console.log("delete", result);
});

Invoice.update( {}, { "$pull": { "attachment.$[].files":{_id:ObjectId("5b7969ac8fb15f3e5c8e844e") } }}, { "multi": true } , function (err, result) { console.log(result); });db.adminCommand( { setFeatureCompatibilityVersion: 3.6 or 4.0 depending on your version } )