Skip to content

feat(orm): add repository pagination with limit and offset #490

Description

@GaspardKirira

Summary

Add explicit pagination support to BaseRepository<T>.

Loading every row with findAll() is unsuitable for large tables and HTTP APIs.

Current behavior

findAll() always executes an unbounded query.

Users must create custom repositories for basic limit and offset pagination.

Expected behavior

Repositories must support bounded result retrieval using valid LIMIT and OFFSET clauses.

The API must remain explicit and predictable.

Scope

  • Add limit-based result retrieval.
  • Add offset support.
  • Define behavior for a zero limit.
  • Validate numeric boundaries.
  • Document the need for deterministic ordering.
  • Support explicit selected columns when available.
  • Add SQLite integration tests.
  • Add MySQL integration tests where available.
  • Preserve findAll().

Suggested API direction

A possible API is findPage(limit, offset).

Another possible direction is a repository query-options structure.

The final API should be reviewed before implementation.

Suggested files

  • modules/orm/include/vix/orm/Repository.hpp
  • modules/orm/include/vix/orm/QueryOptions.hpp
  • modules/orm/tests/repository_pagination_test.cpp
  • modules/orm/examples/...

Acceptance criteria

  • findAll() remains unchanged.
  • A limit restricts the number of returned rows.
  • An offset skips the requested rows.
  • Invalid values fail clearly.
  • Pagination works with SQLite.
  • Generated MySQL SQL remains valid.
  • Pagination values are handled safely.
  • Existing repository code remains compatible.

Non-goals

This issue does not include:

  • cursor pagination;
  • HTTP response generation;
  • automatic total-count queries;
  • relationship pagination.

Suggested labels

  • scope:orm
  • type:feature
  • tests
  • help wanted
  • status:accepted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions