mongo-cursor-pagination icon indicating copy to clipboard operation
mongo-cursor-pagination copied to clipboard

feature(aggregate): added support for 2 additional use-cases while ma…

Open fernando-almeida opened this issue 3 years ago • 0 comments

Changes Made

Added new optional param to aggregate function to support more use-cases

  1. undefined => preserve legacy behavior
  2. null => allow data pre-transformation/summarization prior to pagination
  3. custom user function => allow data post-transformation server-side)

Potential Risks

The assumptions in usage scenario 1 are the same as for 2. In both cases, there's still room for user error, if the user does not consider the established assumptions adequately. The 3rd scenario can lead to even more user errors since the user must be aware that he may be providing additional steps to the pipeline after the pagination operations and as such must take into consideration any prior data transformations. Ultimately, in this scenario, the user could even override the $sort assumption so only advanced users should use it.

Test Plan

The performance implications are directly related with the pipeline data transformation/summarization steps prior to the pagination steps and those that follow for both scenarios 2) and 3) respectively

Checklist

  • [ ] I've increased test coverage

Sorry but at this time I don't have the time to add any additional meaningful tests for the new sample use cases. The changes are "minimal" and I'm convinced that added usefulness at this point suffice to justify this addition even though the additional tests could be helpful even if to explain the use cases better with practical examples. I've attested though that all previous tests still succeed.

  • [x] Since this is a public repository, I've checked I'm not publishing private data in the code, commit comments, or this PR.

fernando-almeida avatar Feb 17 '22 19:02 fernando-almeida