unable to update the array using pull in node.js

Abhishek Soni

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
}]
Sagar Chaudhary

You can use the following solution to solve your problem:

{ $pullAll: { roleAssigned: ['user'] } };

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

React | JavaScript : Unable to update an array using map

分類Dev

how to insert and update data into postgresql from node js using if condition

分類Dev

POSTING an array of objects to node.js/save to database using mongoose

分類Dev

node.js is consuming much ram by using an array

分類Dev

Unable to download file from Google Drive using API - node.js

分類Dev

How to inform and update a client when a new record inserted in mysql database using node js and socket.io

分類Dev

Update an array item in knockout js

分類Dev

Unable to load node.js package

分類Dev

Update datatable using an array of objects

分類Dev

Unable to update the tls-cipher-suites for node exporter in openshift 3.11

分類Dev

Passing an array from node.js to c++ v8 using NAN

分類Dev

how to create custom object/array using twilio fetch conference function in Node.js

分類Dev

Im creating a rest api using node.js and in .get method i want to get back a json array

分類Dev

Unable to pull data from android smartwatch using adb - remote object does not exist

分類Dev

d3.js unable to use general update pattern and transition

分類Dev

Node.js Array to text with newline

分類Dev

Insert array as column in Node.js

分類Dev

accessing an array outside the function in node js

分類Dev

sorting 2d array in node js

分類Dev

Convert JSON Array to Object Node js

分類Dev

Unable to pull from remote server

分類Dev

Unable to Pull EPEL repository Metadata

分類Dev

How to update an array in react using prevState?

分類Dev

Unable to change mysql user password using update statement

分類Dev

Unable to change brightness using keys after recent 13.10 update

分類Dev

How to update html document using feather js?

分類Dev

partial update on an mvc model in razor using js

分類Dev

Node.js: allow process update during loop

分類Dev

How can I update Node.JS through JXCore?

Related 関連記事

  1. 1

    React | JavaScript : Unable to update an array using map

  2. 2

    how to insert and update data into postgresql from node js using if condition

  3. 3

    POSTING an array of objects to node.js/save to database using mongoose

  4. 4

    node.js is consuming much ram by using an array

  5. 5

    Unable to download file from Google Drive using API - node.js

  6. 6

    How to inform and update a client when a new record inserted in mysql database using node js and socket.io

  7. 7

    Update an array item in knockout js

  8. 8

    Unable to load node.js package

  9. 9

    Update datatable using an array of objects

  10. 10

    Unable to update the tls-cipher-suites for node exporter in openshift 3.11

  11. 11

    Passing an array from node.js to c++ v8 using NAN

  12. 12

    how to create custom object/array using twilio fetch conference function in Node.js

  13. 13

    Im creating a rest api using node.js and in .get method i want to get back a json array

  14. 14

    Unable to pull data from android smartwatch using adb - remote object does not exist

  15. 15

    d3.js unable to use general update pattern and transition

  16. 16

    Node.js Array to text with newline

  17. 17

    Insert array as column in Node.js

  18. 18

    accessing an array outside the function in node js

  19. 19

    sorting 2d array in node js

  20. 20

    Convert JSON Array to Object Node js

  21. 21

    Unable to pull from remote server

  22. 22

    Unable to Pull EPEL repository Metadata

  23. 23

    How to update an array in react using prevState?

  24. 24

    Unable to change mysql user password using update statement

  25. 25

    Unable to change brightness using keys after recent 13.10 update

  26. 26

    How to update html document using feather js?

  27. 27

    partial update on an mvc model in razor using js

  28. 28

    Node.js: allow process update during loop

  29. 29

    How can I update Node.JS through JXCore?

ホットタグ

アーカイブ