Skip to content

Add paginated result DTO #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gregbrowndev opened this issue Sep 12, 2023 · 0 comments
Open

Add paginated result DTO #59

gregbrowndev opened this issue Sep 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@gregbrowndev
Copy link
Owner

gregbrowndev commented Sep 12, 2023

For paginated queries, we should return a result type that contains the page info. E.g.

case class PageInfoDTO(offset: Int, limit: Int, records: Int)

case class JobDTO(...)

case class JobsQueryResultDTO(pageInfo: PageInfoDTO, jobs: List[JobDTO])

Note: The offset-based pagination approach used above has some disadvantages. If the data changes (records added/modified/removed) such that the ordering changes, the user may see duplicated results as they paginate through the data.

Additionally, the query contains the total number of records, which entails doing a COUNT(*), to derive the total number of pages. In large datasets, this may be expensive.

We could also include an infinite-scroller style of pagination to avoid page numbering:

case class VirtualPageInfoDTO(offset: Int, limit: Int, hasPreviousPage: Boolean, hasNextPage: Boolean)

And use cursor-based pagination to prevent the other issues.

@gregbrowndev gregbrowndev added the enhancement New feature or request label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant