Array Update Operators

Note

For details on specific operator, including syntax and examples,click on the specific operator to go to its reference page.

Update Operators

NameDescription
$Acts as a placeholder to update the first element that matches the query condition.
$[]Acts as a placeholder to update all elements in an array for the documents that match the query condition.
$[<identifier>]Acts as a placeholder to update all elements that match the arrayFilters condition for the documents that match the query condition.
$addToSetAdds elements to an array only if they do not already exist in the set.
$popRemoves the first or last item of an array.
$pullRemoves all array elements that match a specified query.
$pushAdds an item to an array.
$pullAllRemoves all matching values from an array.

Update Operator Modifiers

NameDescription
$eachModifies the $push and $addToSet operators to append multiple items for array updates.
$positionModifies the $push operator to specify the position in the array to add elements.
$sliceModifies the $push operator to limit the size of updated arrays.
$sortModifies the $push operator to reorder documents stored in an array.