C100DBA practice question 20 of 25
In mongodb how do you update a document partially?
Full set: 130 questionsThe $set operator is the standard field update operator used to perform partial updates on a document. It replaces the value of a specific field with a new value. If the field does not exist in the document, $set adds it. This allows for modifying one or more fields without replacing the entire document, which is efficient and preserves other field data.
A. $project is an aggregation pipeline stage used to reshape the structure of documents in a query result, not to update source documents.
B. $update is not a valid MongoDB update operator. The methods are updateOne() or updateMany(), which use operators like $set.
C. $modify is not a valid MongoDB update operator. The findAndModify command is a method, but it uses operators like $set to perform the modification.
1. MongoDB Manual v7.0
"Update and Replace Documents"
"Field Update Operators"
$set section. (https://www.mongodb.com/docs/v7.0/reference/operator/update/set/)
2. MongoDB Manual v7.0
"CRUD Operations"
"Update Documents in MongoDB" section. (https://www.mongodb.com/docs/v7.0/crud/update-documents/)
Keep practicing
Take the free C100DBA practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other C100DBA practice questions
- Question 1If the value of totalKeysExamined is 30000 and the value of totalDocsExamined is 0, which…
- Question 2The oplog (operations log) is a special capped collection that keeps a rolling record of …
- Question 3‘$set' sets the value of
- Question 4What does the totalKeysExamined field returned by the explain method indicate?
- Question 5Which mongodb tools allow us to work with our data in a human readable format?
- Question 6Which of the following is incorrect statement about find and findOne operations in MongoD…
