I wanted to delete 'user' entry from 'roleAssigned' array In the code:
Contact.update({ firstName:'Abhishek'},{$pull: { roleAssigned:'user'}});
This is what the Contact mongoDB model looks like:
[{
roleAssigned: ['user', 'admin'],
_id: 5b9b8ef904bc042c8f94f1fe,
firstName: 'abhishek',
lastName: 'soni',
date: 2018-09-14T10:35:37.922Z,
__v: 0
}]
"Abhishek"and"abhishek"both are different. Either use smallaor use$regexin your above query. Something like thisContact.update({ firstName:{ $regex: 'Abhishek', $options: "i" }},{ $pull: { roleAssigned: 'user' }})