JCC Express

Pagination

Introduction

JCC-Eloquent provides pagination at both model and builder level.

Both methods read request.query.page and return data + pagination metadata.


Model pagination

Model.paginate(request, perPage?):

TypeScript

This returns:

  • data
  • meta (current_page, per_page, total, total_pages, has_more, links)
  • links (first, last)

Query builder pagination

Builder pagination works on filtered queries:

TypeScript

Use this when pagination must respect custom constraints.


Manual offset/limit alternative

For full manual control:

TypeScript

Notes

  • page is clamped to a minimum of 1.
  • perPage is cast to number internally.
  • Pagination link generation uses request protocol/host/path.

Summary

  • Use User.paginate(req, perPage) for quick model pagination.
  • Use query .paginate(req, perPage) when filtering/sorting is needed.
  • Use offset + limit only for custom manual paging flows.