-
-
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
Cursor operator in Aggregate function not working.. #2306
Comments
I have the same problem with the same versions. This works:
This doesn't work:
|
Thanks for adding it to your milestone. Many thanks, |
Hi, Any progress on this? |
Some progress, but not much unfortunately. We've figured out what's wrong, just haven't had the time to fix it yet. |
+1. Any progress on this? |
So this issue is closed, what sort of problem are you having? |
This works: Model
.aggregate(pipeline)
.exec(function () {
console.log(arguments);
}) And this doesn't: (never calls back) Model
.aggregate(pipeline)
.cursor({ batchSize: 1000 })
.exec(function () {
console.log(arguments);
}) Also, the following doesn't return a promise: Model
.aggregate(pipeline)
.cursor({ batchSize: 1000 })
.exec() Am I missing something? |
Model
.aggregate(pipeline)
.cursor({ batchSize: 1000 })
.exec() returns a cursor, as specified in 4.0 release notes. Admittedly this is a not-well-designed API, it's something that was thrown in at the last minute as a stopgap. The right way to do it would probably be something like this: var stream = Model
.aggregate(pipeline)
.cursor({ batchSize: 1000 })
.exec().stream();
stream.on('data', function(doc) {
// ...
}); |
Yep those docs are incorrect, thanks for pointing that out |
Anyone looking at this may also be interested in #3160 which outlines another bug about getting an undefined response from exec when a cursor is used. |
@vkarpov15 its almost 2018 and the docs are still misleading. someone help 🤔 |
@Ra1da35ma well that's embarrassing, looks like we closed out #2955 by mistake. Thanks for pointing that out, re-opened and will be fixed 👍 |
I returned to the version mongoose": "4.13.7 and everything is normal .. using mongo 3.6 |
This Answer + This One:
Solved my problem. Thanks! |
Hi,
I have the latest mongoose 3.8.16 with mongodb 2.6.4
I am trying to do cursor operation on an aggregate pipeline.
My function looks like,
I printed the raw mongodb query that is built by mongoose (using mongoose.set('debug', true)) which looks like
Please note that cursor operator is outside the aggregate () enclosure
Shouldn't it be like
My hand written raw mongodb query for mongo shell works really well and here is how it looks
Is it a bug or am I missing something?
If someone could shred some light on it would be much appreciated.
Many thank,
Karthik
The text was updated successfully, but these errors were encountered: