MongoDB provides a rich set of positional operators and array-specific operators to update elements within arrays, from modifying the first match to updating all elements or only those meeting specific filter conditions
$push operator adds elements to an array
$pull removes elements that match a condition
$pop removes the first or last element
$addToSet ensures uniqueness for adding elements only if they don't already exist
$ updates the first element matching the query condition
$[] updates all elements in the array
$[<identifier>] updates elements that match an arrayFilters condition
$each modifier allows adding multiple items with $push or $addToSet.
$position modifier controls where elements are inserted, with zero-based indexing.
$slice modifier limits array size, and $sort orders elements during updates
$ operator restrictions: The $ operator cannot be used with upsert operations (inserts will treat $ as a field name). It also cannot be used with queries that traverse multiple nested arrays [citation:9].
$ operator with $unset: When used with $unset, the $ operator sets the matching element to null rather than removing it from the array [citation:9].
Multiple array matches: Using $ with queries that filter on multiple array fields can produce ambiguous results. Use $[<identifier>] with arrayFilters for clearer behavior [citation:9].
$pullAll limitations: For arrays containing objects, $pullAll may not work as expected due to object comparison semantics. Use $pull with specific query conditions instead [citation:8].
Upsert with positional operators: When using upsert, the query must include an exact equality match on the array field for positional operators to work correctly during insert [citation:3].