diff --git a/docs/migrating_to_6.md b/docs/migrating_to_6.md index 48d46d03e30..e8651cf7ccf 100644 --- a/docs/migrating_to_6.md +++ b/docs/migrating_to_6.md @@ -221,7 +221,9 @@ const res = await Test.findOneAndUpdate({}, { $set: { name: undefined } }, { new

Document Parameter to Default Functions

-Mongoose now passes the document as the first parameter to `default` functions, which is helpful for using [arrow functions](https://masteringjs.io/tutorials/fundamentals/arrow) with defaults. This may affect you if you pass a function that expects different parameters to `default`, like `default: mongoose.Types.ObjectId`. See [gh-9633](https://github.com/Automattic/mongoose/issues/9633) +Mongoose now passes the document as the first parameter to `default` functions, which is helpful for using [arrow functions](https://masteringjs.io/tutorials/fundamentals/arrow) with defaults. + +This may affect you if you pass a function that expects different parameters to `default`, like `default: mongoose.Types.ObjectId`. See [gh-9633](https://github.com/Automattic/mongoose/issues/9633). If you're passing a default function that does **not** utilize the document, change `default: myFunction` to `default: () => myFunction()` to avoid accidentally passing parameters that potentially change the behavior. ```javascript const schema = new Schema({