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.

  1. $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.
  2. $currentDate

    The $currentDate operator can set a date field in a document to the current date or time.
  3. $inc

    The MongoDB $inc operator allows us to perform atomic increment operations on specified fields.
  4. $mul

    $mul is an update operator in MongoDB used to multiply the value of a field by a given number.
  5. $pop

    The MongoDB $pop operator is used to remove the first or last element from an array.
  6. $pull

    The MongoDB $pull operator is used to remove elements from an array that match a specific condition.
  7. $pullAll

    The $pullAll operator in MongoDB is used to remove all elements in an array that match a specified value.
  8. $push

    The $push operator is an update operator in MongoDB used to append one or multiple values to the end of an array.
  9. $setOnInsert

    The $setOnInsert operator in MongoDB is used to update a document only if it does not exist while performing an update operation.
  10. $sort

    The MongoDB $sort operator is an important operator in the MongoDB query language, used to sort query results by specified fields.