From f6d5460ada2c53219df3c4af3d84843303f9d48c Mon Sep 17 00:00:00 2001 From: Pete Boere Date: Mon, 2 Oct 2023 14:20:48 +0100 Subject: [PATCH 1/2] Amend some awkward FAQ wording --- docs/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index 282d658324a..862235dd62b 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -139,7 +139,7 @@ is undefined on the underlying [POJO](guide.html#minimize). **Q**. 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 very differently to 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 From 92d3513bdcc8b07c8b89b67592633b7d1cfb86b7 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 3 Oct 2023 14:28:25 -0400 Subject: [PATCH 2/2] Update faq.md --- docs/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index 862235dd62b..8ae6a441b35 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -139,7 +139,7 @@ is undefined on the underlying [POJO](guide.html#minimize). **Q**. 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 very differently to 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