V
V
Valmal422016-06-06 19:50:23
NoSQL
Valmal42, 2016-06-06 19:50:23

What is the essence of the .replaceOne command in MongoDB?

I am taking an online course on MongoDB on their website, but my English is not very good. I don't understand the meaning of the .replaceOne command, please explain.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-06-06
Protko @Fesor

https://docs.mongodb.com/manual/reference/method/d...
google translate:
replaceOne() replaces the first found document in the collection that matches the filter with document replace.
If upsert: is true and no documents match the filter, replaceOne() creates a new document based on the document replacement. See Replace Upsert.

L
lega, 2016-06-06
@lega

replaceOne is essentially the same as updateOne, only updateOne is protected so as not to overwrite the entire document, i.e. must be $set or $addToSet or the like. there are no such restrictions on replaceOne

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question