Skip to content
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

Merged
merged 5 commits into from
Mar 19, 2021

Conversation

IslandRhythms
Copy link
Collaborator

It passed all the already failing tests but now introduces 4 failures.

It passed all the already failing tests but now introduces 4 failures.
@IslandRhythms IslandRhythms linked an issue Mar 11, 2021 that may be closed by this pull request
@@ -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];
Copy link
Collaborator

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.

return co(function*() {
yield Movie.deleteMany({});
yield Movie.create({ name: 'Daniel' }, { name: 'Val' }, { name: 'Daniel' });
yield Movie.find({ name: 'Daniel' }).cursor().eachAsync(doc => {
Copy link
Collaborator

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.

Copy link
Collaborator

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.

@@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making this change here, check what happens if you just make this change when execPost() is called. That's what triggers post hooks.

Also, one place that's always handy to look is the commit where we introduced post hooks for cursors, see #9345 and 4dad667 . That may provide some hints.

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@vkarpov15 vkarpov15 added this to the 5.12.2 milestone Mar 19, 2021
@vkarpov15 vkarpov15 merged commit 422620b into master Mar 19, 2021
@Uzlopak Uzlopak deleted the gh-9982 branch June 14, 2022 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve docs on post find hooks
2 participants