MongoDB Update Operators
MongoDB update operators are a set of special operators used to modify and process specified fields when updating documents. They can be used to add, remove, or modify specified fields when updating documents. This page summarizes the update operators available in MongoDB.
-
$addToSet
The Mongodb$addToSet
operator is used to add elements to an array field in a Mongodb document, but only if the element does not already exist in the array. -
$currentDate
The$currentDate
operator can set a date field in a document to the current date or time. -
$inc
The MongoDB$inc
operator allows us to perform atomic increment operations on specified fields. -
$mul
$mul
is an update operator in MongoDB used to multiply the value of a field by a given number. -
$pop
The MongoDB$pop
operator is used to remove the first or last element from an array. -
$pull
The MongoDB$pull
operator is used to remove elements from an array that match a specific condition. -
$pullAll
The$pullAll
operator in MongoDB is used to remove all elements in an array that match a specified value. -
$push
The$push
operator is an update operator in MongoDB used to append one or multiple values to the end of an array. -
$setOnInsert
The$setOnInsert
operator in MongoDB is used to update a document only if it does not exist while performing anupdate
operation. -
$sort
The MongoDB$sort
operator is an important operator in the MongoDB query language, used to sort query results by specified fields.