MongoDB modify, delete a document stepped pit remember!

1 Update Document

grammar structure

db.集合名称.update(条件,修改后的数据)

Modify _id record 1, point number like 1000, enter the following statement:
After performing found this document in addition to other fields thumbup field are gone.
To solve this problem, we need to use modifiers $ set to achieve the following command:

db.comment.update({_id:"2"},{$set:{thumbup:2000}})

2 Delete Document

grammar structure

db.集合名称.remove(条件)

The following statement will delete all the data, caution ~

db.comment.remove({})

Delete conditions can be placed in braces, such as deleting data thumbup 1000, enter the following statement:

db.comment.remove({thumbup:1000})
Published 380 original articles · won praise 543 · views 330 000 +

Guess you like

Origin blog.csdn.net/qq_33589510/article/details/104929785