DocumentDB LogoDocumentDB
HomeGitHubDiscordDocsBlogs
Back to DocumentationMQL Documentation
CommandsAggregationQuery And Write
OperatorsAccumulatorAggregationArithmetic ExpressionArray ExpressionArray QueryArray UpdateBitwiseBitwise QueryBitwise UpdateBoolean ExpressionComparison QueryConditional ExpressionData SizeDate ExpressionElement QueryEvaluation QueryField UpdateGeospatialLogical QueryMiscellaneousObject ExpressionProjectionSet ExpressionTimestamp ExpressionVariable ExpressionWindow
Reference/Operators/Field Update

MongoDB Query Language (MQL) Field Update Operators

$currentDate

Sets the value of a field to the current date, either as a Date or a timestamp, useful for tracking document modifications.

$inc

Increments the value of a field by a specified amount, creating the field if it doesn't exist, accepting positive and negative values.

$max

Updates a field only if the specified value is greater than the current field value, useful for maintaining maximum values.

$min

Updates a field only if the specified value is less than the current field value, useful for maintaining minimum values.

$mul

Multiplies the value of a field by a specified number, creating the field with value zero if it doesn't exist, useful for scaling and percentage operations.

$rename

Renames fields in documents during update operations, removing the old field name and creating a new field with the same value.

$set

Sets the value of fields in documents, creating new fields if they don't exist or updating existing field values.

$setOnInsert

Sets field values only when an upsert operation results in inserting a new document, having no effect when updating existing documents.

$unset

Removes specified fields from documents, effectively deleting the field and its value entirely.

Copyright © DocumentDB a Series of LF Projects, LLC. For web site terms of use, trademark policy and other project policies please see https://lfprojects.org.