-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Asyncify update validators, SchemaType.prototype.doValidate(), save hooks for improved stack traces
#15312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Asyncify update validators, SchemaType.prototype.doValidate(), save hooks for improved stack traces
#15312
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b20df58
BREAKING CHANGE: make SchemaType.prototype.doValidate() an async func…
vkarpov15 50bca1f
refactor: make validateBeforeSave async for better stack traces
vkarpov15 fae948f
BREAKING CHANGE: make validateBeforeSave async and stop relying on Ka…
vkarpov15 0f6b4aa
address code review comments
vkarpov15 59e9381
remove vestigial :error post hook calls
vkarpov15 92d6ca5
refactor: make saveSubdocsPreSave async
vkarpov15 80a2ed3
style: fix lint
vkarpov15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Migrating from 8.x to 9.x | ||
|
|
||
| <style> | ||
| ul > li { | ||
| padding: 4px 0px; | ||
| } | ||
| </style> | ||
|
|
||
| There are several backwards-breaking changes you should be aware of when migrating from Mongoose 8.x to Mongoose 9.x. | ||
|
|
||
| If you're still on Mongoose 7.x or earlier, please read the [Mongoose 7.x to 8.x migration guide](migrating_to_8.html) and upgrade to Mongoose 8.x first before upgrading to Mongoose 9. | ||
|
|
||
| ## `Schema.prototype.doValidate()` now returns a promise | ||
|
|
||
| `Schema.prototype.doValidate()` now returns a promise that rejects with a validation error if one occurred. | ||
| In Mongoose 8.x, `doValidate()` took a callback and did not return a promise. | ||
|
|
||
| ```javascript | ||
| // Mongoose 8.x function signature | ||
| function doValidate(value, cb, scope, options) {} | ||
|
|
||
| // Mongoose 8.x example usage | ||
| schema.doValidate(value, function(error) { | ||
| if (error) { | ||
| // Handle validation error | ||
| } | ||
| }, scope, options); | ||
|
|
||
| // Mongoose 9.x function signature | ||
| async function doValidate(value, scope, options) {} | ||
|
|
||
| // Mongoose 9.x example usage | ||
| try { | ||
| await schema.doValidate(value, scope, options); | ||
| } catch (error) { | ||
| // Handle validation error | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.