-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
BREAKING CHANGE: remove support for callbacks in pre middleware #15599
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
base: 9.0
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -886,9 +886,9 @@ describe('aggregate: ', function() { | |||||
const s = new Schema({ name: String }); | ||||||
|
||||||
let called = 0; | ||||||
s.pre('aggregate', function(next) { | ||||||
s.pre('aggregate', function() { | ||||||
++called; | ||||||
next(); | ||||||
return Promise.resolve(); | ||||||
}); | ||||||
|
||||||
const M = db.model('Test', s); | ||||||
|
@@ -902,9 +902,9 @@ describe('aggregate: ', function() { | |||||
it('setting option in pre (gh-7606)', async function() { | ||||||
const s = new Schema({ name: String }); | ||||||
|
||||||
s.pre('aggregate', function(next) { | ||||||
s.pre('aggregate', function() { | ||||||
this.options.collation = { locale: 'en_US', strength: 1 }; | ||||||
next(); | ||||||
return Promise.resolve(); | ||||||
}); | ||||||
vkarpov15 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
const M = db.model('Test', s); | ||||||
|
@@ -920,9 +920,9 @@ describe('aggregate: ', function() { | |||||
it('adding to pipeline in pre (gh-8017)', async function() { | ||||||
const s = new Schema({ name: String }); | ||||||
|
||||||
s.pre('aggregate', function(next) { | ||||||
s.pre('aggregate', function() { | ||||||
this.append({ $limit: 1 }); | ||||||
next(); | ||||||
return Promise.resolve(); | ||||||
}); | ||||||
vkarpov15 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
const M = db.model('Test', s); | ||||||
|
@@ -980,8 +980,8 @@ describe('aggregate: ', function() { | |||||
const s = new Schema({ name: String }); | ||||||
|
||||||
const calledWith = []; | ||||||
s.pre('aggregate', function(next) { | ||||||
next(new Error('woops')); | ||||||
s.pre('aggregate', function() { | ||||||
return Promise.reject(new Error('woops')); | ||||||
|
return Promise.reject(new Error('woops')); | |
throw new Error('woops'); |
Copilot uses AI. Check for mistakes.
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.
Curious if it'll make a difference to throw
an error within a synchronous function compared to an async
function. Will both errors be handled the same way?
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.
Yes. I made this change in f41de58 and it still works. Kareem does wrap pre hook execution in try/catch.
Uh oh!
There was an error while loading. Please reload this page.