Field Update Operators

Note

For details on specific operator, including syntax and examples, click on the specific operator to go to its reference page.

Name名称Description描述
$currentDate Sets the value of a field to current date, either as a Date or a Timestamp.将字段的值设置为当前日期(作为日期或时间戳)。
$inc Increments the value of the field by the specified amount.将字段的值增加指定的量。
$min Only updates the field if the specified value is less than the existing field value.仅当指定值小于现有字段值时才更新字段。
$max Only updates the field if the specified value is greater than the existing field value.仅当指定值大于现有字段值时才更新字段。
$mul Multiplies the value of the field by the specified amount.将字段的值乘以指定的量。
$rename Renames a field.重命名字段。
$set Sets the value of a field in a document.设置文档中字段的值。
$setOnInsert 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.对修改现有文档的更新操作没有影响。
$unset Removes the specified field from a document.从文档中删除指定的字段。