3.4.3 Data Update operations
MongoDB data is a copy of the data, the final data will be kept in the traditional database, so if the data in the relational database changed, the best way is to delete the inside of the MongoDB data reinserted.
In MongoDB, there are two types of functions available for updating data: Save (), update ()
Basic use of the 3.4.3.1 function
The most straightforward use of the data is the update () function, but the update () function syntax requires a lot of trouble.
- Syntax: DB. Collection. Update (updated condition, new object data, Upsert, multi)
New Object data: There can be some operators.
Upsert: The updated data does not exist, then a new content is added (true to increase, false to not increase)
Multi: Indicates whether only the first row of records is satisfied (set to False, update only the first one, true full update)
Example : Update the scores of people aged 19 to 100 (multiple data will be returned)
MongoDB (Lesson 17 update function)