September 2017
Intermediate to advanced
450 pages
11h 24m
English
Mongoose's document API provides tools for working with retrieved documents from the model API. These APIs are in some ways very similar to the model API but are scoped to the specific document:
| Property | Example | Description |
| increment | post.increment(); | Will increment a document's version upon save. |
| model | post.model('Author') | Returns another model instance. |
| remove | post.remove(); | Removes this document from the db. |
| save | post.save(); | Saves this document in its current state to MongoDB. |
| $where | post.$where('this.title !== "foobar"').exec(function (error, docs) {}); | Allows you to provide a JavaScript expression as a query to MongoDB. |
| base | post.base; | If using discriminators, this is an instance of the base model ... |
Read now
Unlock full access