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

Using $facet instead of two queries & adding paginateExec to Aggregate #36

Closed claude-abounegm closed 3 years ago

claude-abounegm commented 3 years ago

This pull request contains two features:

If countQuery and useFacet, two queries will still be executed, and facet will be ignored.

Breaking Changes:

aravindnc commented 3 years ago

@claude-abounegm Much thanks.

aravindnc commented 3 years ago

@claude-abounegm Can you add a test case too.

claude-abounegm commented 3 years ago

@aravindnc will do soon!

saminndex commented 2 months ago

FYI there's a breaking change that's not mentioned which means you cannot use $geoNear queries when useFacet is set to true with the error message $geoNear is not allowed to be used within a $facet stage so if you're using this in your aggregatepaginate query using the mongoose-aggregate-paginate-v2 package, you'll need to set this to false. Further reading: https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/