querydrill

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

2
  1. $push, $addToSet and $pull

    MongoDB array updates: $push to append, $addToSet to append only if absent, $pull to remove matching elements.

  2. The positional $ operator

    Update an object inside a MongoDB array with the positional $ operator, which targets the element your filter matched.

Drills

1 easy · 1 medium · 1 hard
Start reading →Skip to the drills