I want to remove a specific element from array stored in mongodb document. I am using this:
model.registerCompany.findOneAndUpdate({companyKey:"a key"},
{$pop:{onlineEmployees:"John"}},
function(err,doc){
if(!err)
console.log("Online list modified: ",doc);
else
console.log("Online list modified error :",err);
});
But I am not sure if the $pop removes the specific element "John" from array(onlineEmployees) or just pop out the last element from it.
Am i doing it right or there is another way to do it.?
I think i got the answer .. $pull is used for this purpose as explained here in the link:
http://docs.mongodb.org/manual/reference/operator/pull/#_S_pull