MongoDB Query Language (MQL) Array Update Operators

$addToSet

The `$addToSet` operator adds a value to an array only if the value is not already present in the array.

$each

The `$each` modifier is used with $push and $addToSet operators to add multiple values to an array field.

$[<identifier>]

The `$[<identifier>]` array update operator is used to update specific elements in an array that match a given condition. This operator is useful when you need to update multiple elements within an array based on certain criteria. It allows for more granular updates within documents, making it a powerful tool for managing complex data structures.

$[]

The `$[]` all positional operator updates all elements in an array for the documents that match the query condition.

$pop

The `$pop` operator is used to remove the first or last element of an array. This operator is useful when you need to manage arrays by removing elements from either end. The `$pop` operator can be used in update operations.

$position

The `$position` operator is used to specify the position in the array where a new element should be inserted. This operator is useful when you need to insert an element at a specific index in an array rather than appending it to the end.

$pull

The `$pull` operator removes from an existing array all instances of a value or values that match a specified condition.

$pullAll

The `$pullAll` operator removes all instances of the specified values from an existing array.

$push

The `$push` operator is used to add a specified value to an array within a document. The $push operator adds new elements to an existing array without affecting other elements in the array.

$slice

The `$slice` modifier limits the number of array elements during a $push operation.

$sort

The `$sort` modifier orders the elements of an array during a $push operation.

$

The `$` positional operator identifies an element in an array to update without explicitly specifying the position of the element in the array. The `$` operator acts as a placeholder for the first element that matches the query condition, and the array field must appear as part of the query document.