-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix? hooks now return an array only and typescript bugs fixed? #10015
Conversation
It passed all the already failing tests but now introduces 4 failures.
lib/cursor/QueryCursor.js
Outdated
@@ -480,7 +480,8 @@ function _waitForCursor(ctx, cb) { | |||
*/ | |||
|
|||
function _create(ctx, doc, populatedIds, cb) { | |||
const instance = helpers.createModel(ctx.query.model, doc, ctx.query._fields); | |||
doc = [doc]; |
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.
Why is this here? createModel()
takes in a single document as a param, not an array.
test/query.cursor.test.js
Outdated
return co(function*() { | ||
yield Movie.deleteMany({}); | ||
yield Movie.create({ name: 'Daniel' }, { name: 'Val' }, { name: 'Daniel' }); | ||
yield Movie.find({ name: 'Daniel' }).cursor().eachAsync(doc => { |
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.
eachAsync()
should pass a doc, not an array of docs, to the callback. This would be a massive breaking change.
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.
You only want to change how post hooks work, not how everything else about query cursors works.
lib/cursor/QueryCursor.js
Outdated
@@ -480,7 +480,7 @@ function _waitForCursor(ctx, cb) { | |||
*/ | |||
|
|||
function _create(ctx, doc, populatedIds, cb) { | |||
const instance = helpers.createModel(ctx.query.model, doc, ctx.query._fields); | |||
const instance = helpers.createModel(ctx.query.model, [doc], ctx.query._fields); |
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.
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.
Thanks 👍
It passed all the already failing tests but now introduces 4 failures.