Skip to content

Add paginated result DTO #59

@gregbrowndev

Description

@gregbrowndev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions