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
[1.7.0.1] Meteor.wrapAsync no longer works, returning a cursor instead of ajax results #9936
Comments
I think we may be seeing this in Reaction as well. |
I think it is a change on the mongo driver, add a .toArray at the end, this will return a promise that you can get on the client. |
@sabativi Works wonderfully. But I struggle to find a way to resolve the promise. I need to get the results, and process them before returning them to clients. I know await can do that but I have to put it in an async function, which is not always possible. |
@sabativi is right, the new 3.x version of the MongoDB driver passes an
The callback arguments are documented here: http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#~aggregationCallback. @WayneUong You can use Meteor's import { Promise } from "meteor/promise";
// ...
// `aggregate` returns a cursor, so you don't need a callback or `wrapAsync`!
const result = Promise.await(rawDonations.aggregate(pipeline).toArray()); |
@see meteor/meteor#9936 - aggregate() now returns a cursor instead of a resolved array
@see meteor/meteor#9936 - aggregate() now returns a cursor instead of a resolved array
We use
Meteor.wrapAsync
to access the collection aggregation up until meteor 1.6. But after upgrading to 1.7.0.1, the returned result is now a AggregationCursor
and no longer a aggregation result.The text was updated successfully, but these errors were encountered: