Docs HomeMongoDB Manual

Field Update Operators字段更新运算符

Note

For details on a specific operator, including syntax and examples, click on the link to the operator's 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.从文档中删除指定的字段。