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

Cursor support for aggregations #174

Open
mikeiwi opened this issue Jun 28, 2016 · 3 comments
Open

Cursor support for aggregations #174

mikeiwi opened this issue Jun 28, 2016 · 3 comments

Comments

@mikeiwi
Copy link

mikeiwi commented Jun 28, 2016

According to pymongo you can pass a kwarg parameter useCursor in an aggregate call so the returned value will be a cursor instead of a document with the whole query result. This seems to be not working with txmongo, I'm getting a aggregate() got an unexpected keyword argument 'useCursor' error.

This is a sample of the code I'm running:

coll.aggregate([{"$unwind": "$fieldName"}], full_response=False, useCursor=True)

I also checked the aggregate method in collection.py but couldn't find anything related to a cursor, only **kwargs (just like in pymongo), but they seem to be not working.

Am I missing something here maybe?, Thank you so much for your help.

@trenton42
Copy link
Contributor

trenton42 commented Jun 28, 2016

@miketb24 A lot of the deep internals in txmongo (especially things that deal with IO, like cursors) are not directly compatible with pymongo. It is very difficult (if not impossible) to directly iterate over something in Twisted that depends on IO in the middle of a loop.

Perhaps the documentation should be more clear to point those differences out.

@IlyaSkriblovsky
Copy link
Contributor

@miketb24 TxMongo doesn't have cursor support for aggregate for now. But patches are welcome :-)

@IlyaSkriblovsky
Copy link
Contributor

Quick research on the topic showed that aggregate command with cursor:{} returns a document of different shape: it contains the cursor id (possibly 0) and the first batch of results.
The solution would be to extract cursor consuming logic from find_with_cursor and use it in both find_with_cursor and aggregate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants