Difference between Document and Query in mongoose?

Viewed 103

According to the mongoose documentation:

Mongoose models provide several static helper functions for CRUD operations. Each of these functions returns a mongoose Query object.

Models are fancy constructors compiled from Schema definitions.

Mongoose documents represent a one-to-one mapping to documents as stored in MongoDB. Each document is an instance of its Model.

Now, all the static CRUD functions on the Model return a Query. However, in the documents section, under guides, it says "When you load documents from MongoDB using model functions like findOne(), you get a Mongoose document back.".

At one place Model.findOne() is returning a Query object and at a different section its returning a document...Can someone please help explain this.

0 Answers
Related