Skip to content

Commit

Permalink
Merge pull request #13925 from peteboere/patch-1
Browse files Browse the repository at this point in the history
Amend some awkward FAQ wording
  • Loading branch information
vkarpov15 authored Oct 3, 2023
2 parents 803fd5b + 92d3513 commit fde2bec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ is undefined on the underlying [POJO](guide.html#minimize).

<a class="anchor" href="#arrow-functions">**Q**</a>. I'm using an arrow function for a [virtual](guide.html#virtuals), [middleware](middleware.html), [getter](api/schematype.html#schematype_SchemaType-get)/[setter](api/schematype.html#schematype_SchemaType-set), or [method](guide.html#methods) and the value of `this` is wrong.

**A**. Arrow functions [handle the `this` keyword much differently than conventional functions](https://masteringjs.io/tutorials/fundamentals/arrow#why-not-arrow-functions).
**A**. Arrow functions [handle the `this` keyword differently than conventional functions](https://masteringjs.io/tutorials/fundamentals/arrow#why-not-arrow-functions).
Mongoose getters/setters depend on `this` to give you access to the document that you're writing to, but this functionality does not work with arrow functions. Do **not** use arrow functions for mongoose getters/setters unless do not intend to access the document in the getter/setter.

```javascript
Expand Down

0 comments on commit fde2bec

Please sign in to comment.