MongoDB TutorialLesson 8Free preview
MongoDB Update
This lesson is part of MongoDB · All levels
Summary
This lesson explains document updates using updateOne() and updateMany(). Updates typically use the $set operator to change a particular field without touching another field, and the modifiedCount reports how many documents have changed. The findOneAndUpdate() method can even restore documents once they have been updated.
Key points
- UpdateOne() updated one document; updateMany() updated all that fit
- The $set operator changes the value of a particular field without deleting another field
- The results of the update contain matchedCount and modifiedCount
- FindOneAndUpdate can restore the updated document
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.