MongoDBUpdate Operators
Posted Rand Tsui
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MongoDBUpdate Operators相关的知识,希望对你有一定的参考价值。
Update Operators
Fields
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
Operators
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 | |
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
Name | Description |
---|---|
Modifies the | |
Modifies the | |
Modifies the | |
Modifies the |
Bitwise
Name | Description |
---|---|
Performs bitwise |
参考:https://docs.mongodb.com/manual/reference/operator/update/
以上是关于MongoDBUpdate Operators的主要内容,如果未能解决你的问题,请参考以下文章
Mongodb update() 与 findAndModify() 性能对比