-
Book Overview & Buying
-
Table Of Contents
Mongoose for Application Development
By :
There are three static methods for updating data in a single go:
update(): This method updates matching documents in the database without returning them
findOneAndUpdate(): This method has the same approach as findOne that we looked at earlier, but writes the updates to the database before returning the found instance to the callback
findByIdAndUpdate(): This method is the same as findOneAndUpdate, but expects a unique ID instead of query object
Each of these methods can take the following four arguments:
conditions: These are the query conditions (or _id for findByIdAndUpdate) used to find documents to update
update: This is an object containing the fields and values to set
options: This is an object specifying options for this operation (see more details about this in just a moment)
callback: This is the function to run after a successful operation
The options differ depending on the call made. The update() method has one set of options you can set...
Change the font size
Change margin width
Change background colour