1.

How do you Update a Document?

Answer»

Once a document is stored in the database, it can be changed USING one of several UPDATE methods: updateOne, updateMany, and replaceOne. updateOne and updateMany each takes a filter document as their first parameter and a modifier document, which describes changes to make, as the second parameter. replaceOne also takes a filter as the first parameter, but as the second parameter replaceOne expects a document with which it will replace the document matching the filter.

For example, in order to replace a document:

{ "_id" : ObjectId("4b2b9f67a1f631733d917a7a"), "NAME" : "alice", "friends" : 24, "enemies" : 2}


Discussion

No Comment Found