aravindnc / mongoose-aggregate-paginate-v2

A cursor based custom aggregate pagination library for Mongoose with customizable labels.
MIT License
131 stars 23 forks source link

Added option to specify the query used to count the number of records #23

Closed SayakMukhopadhyay closed 4 years ago

SayakMukhopadhyay commented 4 years ago

Right now the aggregation pipeline uses the same pipeline for calculating the number of records. This can create a challenge when the aggregation is complicated and/or the number of matched records is too large.

In such a scenario, using a custom count pipeline can help in processing the pagination much faster. I have got improvements in the order of 100 times in a query I required.

This PR allows creates an option to pass their own count pipeline.

aravindnc commented 4 years ago

@SayakMukhopadhyay Thanks. Can you update the readme also.

SayakMukhopadhyay commented 4 years ago

Done!

aravindnc commented 4 years ago

@SayakMukhopadhyay Lot of typos in the readme.

SayakMukhopadhyay commented 4 years ago

Where exactly are they? If you point them out I can create a new PR.

aravindnc commented 4 years ago

@SayakMukhopadhyay No worries. I fixed it. Thanks.