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
}]
You can use the following solution to solve your problem:
{ $pullAll: { roleAssigned: ['user'] } };
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加