this is the structure in mongodb
{ code:'ACBD5588',
email:'owner@mail.com',
object{
array_doc:[//many documents with this structure
{
code_doc:'ANCB7894',
info_doc:'....',
//etc
}
],
counting:45,
}
}
im trying to delete a document inside an array, this document haas a unique code_array so in the array there are many documents with a unique code_array, i want to erase the document inside the array
db.collection('database').findAndModify(
{
'code':code,
'email':email,
},[],{$pull:{'object.array_doc':{'code_doc':code_doc}}},function(err,resultado)
{
but the operation gives me this error
uncaught exception: findAndModifyFailed failed: { "errmsg" :
"need remove or update", "ok" : 0 }