diff --git a/docs/middleware.md b/docs/middleware.md index ca5e2f1f4ed..b74452affbd 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -175,7 +175,7 @@ schema.pre('save', function(next) { }); ``` -

Use Cases

+### Use Cases Middleware are useful for atomizing model logic. Here are some other ideas: @@ -184,7 +184,7 @@ Middleware are useful for atomizing model logic. Here are some other ideas: * asynchronous defaults * asynchronous tasks that a certain action triggers -

Errors in Pre Hooks

+### Errors in Pre Hooks {#error-handling} If any pre hook errors out, mongoose will not execute subsequent middleware or the hooked function. Mongoose will instead pass an error to the callback diff --git a/docs/subdocs.md b/docs/subdocs.md index eeb4c2973b0..5bd37433435 100644 --- a/docs/subdocs.md +++ b/docs/subdocs.md @@ -313,7 +313,7 @@ doc.level1.level2.parent() === doc.level1; // true doc.level1.level2.ownerDocument() === doc; // true ``` -

Alternate declaration syntax for arrays

+### Alternate declaration syntax for arrays {#altsyntaxarrays} If you create a schema with an array of objects, Mongoose will automatically convert the object to a schema for you: diff --git a/docs/tutorials/lean.md b/docs/tutorials/lean.md index 404d352de4f..e11641449d1 100644 --- a/docs/tutorials/lean.md +++ b/docs/tutorials/lean.md @@ -12,7 +12,7 @@ In this tutorial, you'll learn more about the tradeoffs of using `lean()`. * [Plugins](#plugins) * [BigInts](#bigints) -

Using Lean

+## Using Lean By default, Mongoose queries return an instance of the [Mongoose `Document` class](../api/document.html#Document). Documents are much @@ -53,7 +53,7 @@ and virtuals don't run if you enable `lean`. [require:Lean Tutorial.*getters and virtuals] ``` -

Lean and Populate

+## Lean and Populate [Populate](../populate.html) works with `lean()`. If you use both `populate()` and `lean()`, the `lean` option propagates to the @@ -70,7 +70,7 @@ populated documents as well. In the below example, both the top-level [require:Lean Tutorial.*virtual populate] ``` -

When to Use Lean

+## When to Use Lean If you're executing a query and sending the results without modification to, say, an [Express response](http://expressjs.com/en/4x/api.html#res), you should