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描述
$currentDateSets the value of a field to current date, either as a Date or a Timestamp.将字段的值设置为当前日期,可以是日期或时间戳。
$incIncrements the value of the field by the specified amount.将字段的值增加指定的量。
$minOnly updates the field if the specified value is less than the existing field value.仅当指定值小于现有字段值时才更新字段。
$maxOnly updates the field if the specified value is greater than the existing field value.仅当指定值大于现有字段值时才更新字段。
$mulMultiplies the value of the field by the specified amount.将字段的值乘以指定的量。
$renameRenames a field.重命名字段。
$setSets the value of a field in a document.设置文档中字段的值。
$setOnInsertSets 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.对修改现有文档的更新操作没有影响。
$unsetRemoves the specified field from a document.从文档中删除指定字段。
←  Update Operators$currentDate →