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$addToSetoperator 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$currentDateoperator can set a date field in a document to the current date or time. -
$inc
The MongoDB$incoperator allows us to perform atomic increment operations on specified fields. -
$mul
$mulis an update operator in MongoDB used to multiply the value of a field by a given number. -
$pop
The MongoDB$popoperator is used to remove the first or last element from an array. -
$pull
The MongoDB$pulloperator is used to remove elements from an array that match a specific condition. -
$pullAll
The$pullAlloperator in MongoDB is used to remove all elements in an array that match a specified value. -
$push
The$pushoperator is an update operator in MongoDB used to append one or multiple values to the end of an array. -
$setOnInsert
The$setOnInsertoperator in MongoDB is used to update a document only if it does not exist while performing anupdateoperation. -
$sort
The MongoDB$sortoperator is an important operator in the MongoDB query language, used to sort query results by specified fields.