-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(schema+types): add { errorHandler: true }
option to Schema post()
for better TypeScript support
#12723
Conversation
…st()` for better TypeScript support Fix #12595
This PR maybe should be changed to a "Draft" (WIP) PR, so that it can not be accidentally merged (even if tests are failing) |
@hasezoey good suggestion. But can you please review this PR and mongoosejs/kareem#34 anyway? This PR is ready to go, just hard to test because it requires a PR from a separate repo. Tests pass locally, I just want to make sure the API design makes sense. |
will try, when the required lower PR is merged and this PR is updated to actually use that package instead of relative path |
Co-authored-by: hasezoey <hasezoey@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
and "finally" kareem shipped a new version which cut the size in less than half (thanks to not including useless files like tests anymore)
for reference, 2.4.1
was 109 kB
and 2.5.0
is 38.9 kB
(bundle size as reported by npm)
Fix #12583
Summary
Requires mongoosejs/kareem#34 . You can now do
schema.post('save', { errorHandler: true }, async function(err) { ... })
. This means you can use error handling middleware without explicitly listing out arguments, and also makes TypeScript better able to infer the type of params to error handling middleware.Examples