Learn › MongoDB fundamentals
Updating arrays
$push, $addToSet, $pull, and editing an object inside an array.
By the end: Modify array contents in place, without reading the document first.
Lessons
- $push, $addToSet and $pull
MongoDB array updates: $push to append, $addToSet to append only if absent, $pull to remove matching elements.
- The positional $ operator
Update an object inside a MongoDB array with the positional $ operator, which targets the element your filter matched.