Docs Home → Develop Applications → MongoDB Manual
Update Operators![](/docs/v4.4/assets/link.svg)
On this page
The following modifiers are available for use in update operations;
e.g. in db.collection.update()
and
db.collection.findAndModify()
.
Compatibility![](/docs/v4.4/assets/link.svg)
You can use update operators for deployments hosted in the following environments:
MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
MongoDB Enterprise: The subscription-based, self-managed version of MongoDB
MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB
Syntax![](/docs/v4.4/assets/link.svg)
Specify the operator expression in a document of the form:
{ <operator1>: { <field1>: <value1>, ... }, <operator2>: { <field2>: <value2>, ... }, ... }
Note
For details on a specific operator, including syntax and examples, click on the link to the operator's reference page.
Update Operators![](/docs/v4.4/assets/link.svg)
Behavior![](/docs/v4.4/assets/link.svg)
In MongoDB 4.4 and earlier, update operators process all document fields in lexicographic order.
In MongoDB 5.0 and later, update operators process document fields with string-based names in lexicographic order. Fields with numeric names are processed in numeric order.
Consider this example $set
command:
{ $set: { "a.2": <new value>, "a.10": <new value>, } }
In MongoDB 4.4, "a.10"
is processed before "a.2"
because 10
comes before 2
in lexicographic order.
In MongoDB 5.0, "a.2"
is processed before "a.10"
because 2
comes before 10
in numeric order.
Fields![](/docs/v4.4/assets/link.svg)
Name | Description |
---|---|
Sets the value of a field to current date, either as a Date or a Timestamp. | |
Increments the value of the field by the specified amount. | |
Only updates the field if the specified value is less than the existing field value. | |
Only updates the field if the specified value is greater than the existing field value. | |
Multiplies the value of the field by the specified amount. | |
Renames a field. | |
Sets the value of a field in a document. | |
Sets the value of a field if an update results in an insert of a document. Has no effect on update operations that modify existing documents. | |
Removes the specified field from a document. |
Array![](/docs/v4.4/assets/link.svg)
Operators![](/docs/v4.4/assets/link.svg)
Name | Description |
---|---|
Acts as a placeholder to update the first element that matches the query condition. | |
Acts as a placeholder to update all elements in an array for the documents that match the query condition. | |
Acts as a placeholder to update all elements that match the arrayFilters condition for the documents that match the query condition. | |
Adds elements to an array only if they do not already exist in the set. | |
Removes the first or last item of an array. | |
Removes all array elements that match a specified query. | |
Adds an item to an array. | |
Removes all matching values from an array. |
Modifiers![](/docs/v4.4/assets/link.svg)
Bitwise![](/docs/v4.4/assets/link.svg)
Name | Description |
---|---|
Performs bitwise AND , OR , and XOR updates of integer values. |