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
AggregationCursor from collection is missing method eachASync #13334
Comments
What indicates to you that Here's how you get an aggregation cursor: const cursor = MyModel.
aggregate([{ $match: { name: 'test' } }, { $project: { name: '$name' } }]).
cursor();
await cursor.eachAsync(doc => console.log(doc)); |
I specifically said collection in my title and the description. I have clearly shown in my sample code that accessing via the model works, but NOT when accessing the collection directly. That is what my ticket was about. |
I'm sorry, I misread. That's because |
Just to finish this off, and in case it helps anyone who hits this thread for info, the page https://mongoosejs.com/docs/api/connection.html#Connection.prototype.collection() documents that this method returns a "Collection" collection instance, and provides no further information, but advises to using a model instead. |
docs(connection+model): expand docs on accessors for underlying collections
Prerequisites
Mongoose version
7.0.5
Node.js version
16.14.2
MongoDB server version
5.0.12
Typescript version (if applicable)
No response
Description
The observed behaviour of an AggregationCursor from a collection does not align with the documentation at https://mongoosejs.com/docs/api/aggregationcursor.html
Steps to Reproduce
However, the next() and asyncIterator DO work:
Expected Behavior
The AggregationCursor object is expected to be in line with the documentation, but the eachASync method is missing.
Per the documentation, addCursorFlag and close methods are also available to call.
The text was updated successfully, but these errors were encountered: