MongoDB uses the update () and Save () methods to update the documents in the collection
Parameter description:
- Query: The search condition for update, similar to where in SQL update query.
- Update: Update object and some updated operators (such as $, $inc ... ) can also be understood as the SQL update query within the set after the
- upsert : Optional, this parameter means that if there is no record of update, insert objnew,true as INSERT, default is False, do not insert.
- multi : Optional, mongodb default is False, only update the first record found, if this parameter is true, will be found on the condition of a number of records update all.
- writeconcern : Optional, throws an exception level.
1. Add a field. Table represents the name of the sheet, adds a field type, an integer type, and a value of 1.
Db.getcollection (' article '). Update ({}, {$set: {type:numberint (' 1 ')}}, {multi:true})
2. Delete a field
Db.getcollection (' article '). Update ({},{$unset: {content: ""}},false, True)
Transferred from: https://www.cnblogs.com/crystaltu/p/6932377.html
MongoDb Add + delete field to table