Skip to main content
When working with large datasets, pagination is essential for performance and user experience. Esix provides a built-in paginate helper as well as the lower-level skip and limit methods.

paginate()

paginate(page, perPage) returns the requested page of results along with all the metadata you need to render a paginator. Pages are 1-indexed.
The same method is available as a static helper on the model:
paginate validates its arguments and throws if page or perPage is not a positive integer.

Manual Pagination with skip and limit

When you need finer control, you can use skip to offset results and limit to control page size directly:
If you are looping over skip/limit pages to process a whole collection, use batch processing with chunk or cursor instead. Offset loops can skip documents when the loop body modifies them.

Pagination with Sorting

When paginating, it’s important to use consistent sorting to ensure stable results across pages:
This guide covers the pagination capabilities available in Esix. For more information about query methods, see the Retrieving Models guide.