MongoDB TutorialLesson 11Free preview
MongoDB Update Operators
This lesson is part of MongoDB · All levels
Summary
This lesson introduces the MongoDB update operator that modifies a portion of a document without replacing it entirely. In addition to $set, there are $unset to delete fields, $inc to add values, $push and $pull to manage arrays, and $rename to change field names. The use of the operator keeps the other data intact as the update takes place.
Key points
- $set changes the value, $unset removes the field, and $inc adds the number
- Adding elements to arrays, pulling out the matching elements
- $rename replaces a field name
- The update operator can be combined in one command
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.