Fix/pagination#352
Conversation
Reviewer's Guide by SourceryThis pull request addresses issues with sorting and cursor-based pagination in the MongoDB repository implementation. The changes include refactoring the pagination logic to support sorting by different fields, updating the 'cursorToStruct' function to return additional data, and modifying the 'Find' and 'FindPaginated' methods to handle these changes. New dependencies 'github.com/PaesslerAG/jsonpath' and 'github.com/PaesslerAG/gval' were added to support the new functionality. File-Level Changes
Tips
|
There was a problem hiding this comment.
Hey @abdheshnayak - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
| } | ||
|
|
||
| func cursorToStruct[T any](ctx context.Context, curr *mongo.Cursor) ([]T, error) { | ||
| func cursorToStruct[T any](ctx context.Context, curr *mongo.Cursor) ([]T, []map[string]any, error) { |
There was a problem hiding this comment.
suggestion: Consider renaming the second return value for clarity
The second return value []map[string]any could be renamed to something more descriptive, like rawResults, to make the code more readable and self-explanatory.
* 🐛 Fixed cursor-pagination with sorting --------- Co-authored-by: Karthik <karthik@kloudlite.io>
Summary by Sourcery
This pull request fixes issues with sorting and cursor-based pagination in the MongoDB repository. It enhances the pagination logic to dynamically determine the cursor key and correctly handle both ascending and descending sort directions. Additionally, new dependencies were added to support these changes.