mixmaxhq / mongo-cursor-pagination

Cursor-based pagination for Mongo
https://www.mixmax.com/careers
MIT License
229 stars 72 forks source link

Issue with aggregate and $group #58

Open felixveysseyre opened 5 years ago

felixveysseyre commented 5 years ago

Hi !

I am not deeply familiar with MongoDB aggregation mechanism but while trying to use the aggregate method implemented by mongo-cursor-pagination, I ran into troubles.

I could be wrong but it seems that the pagination mechanism works by getting one more element than the limit parameter passed by the user, and depending on the number of documents found, can guess if there is another page after. This particular mechanism is broken if you use a $group instruction inside your aggregation pipeline because the number of results is therefore changed.

soumyabardhan commented 5 years ago

I am also facing similar issues. It doesn't work with $group

bradvogel commented 5 years ago

You're right this doesn't work with $group. Happy to take PRs to update the readme to note this :)