You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
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.
I may be wrong but this works for me, my app is in production with 1.7 and it is the only things that I had to do.
@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 AggregationCursor to the callback, whereas the 2.x version passed the aggregation result. From the driver changelog:
Collection.prototype.aggregate now returns a cursor if a callback is provided. It used to return the resulting documents which is the same as calling cursor.toArray() on the cursor we now pass to the callback.