Understanding the Query Object
Once you have the Schema object compiled into a Model object, you are completely ready to begin accessing, adding, updating, and deleting documents in the model, which makes the changes to the underlying MongoDB database. However, before you jump in, you need to understand the nature of the Query object provided with Mongoose.
Many of the methods in the Model object match those in the Collection object defined in Chapter 13. For example, there are find(), remove(), update(), count(), distinct(), and aggregate() methods. The parameters for these methods are for the most part exactly the same as for the Collection object, with a major difference: the callback parameter.
Using the Mongoose Model object, you can either ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access