module

Lustra::SQL::Query::WithPagination

Constants

DEFAULT_LIMIT = 50
DEFAULT_PAGE = 1

Instance methods

current_page

Return the current page

Source
first_page?
Source
last_page?
Source
next_page

Return current_page + 1 or nil if there is no next page

Source
out_of_bounds?

Helper method that is true when someone tries to fetch a page with a larger number than the last page. Can be used in combination with flashes and redirecting.

Source
paginate(page : Int32 = DEFAULT_PAGE, per_page : Int32 = DEFAULT_LIMIT)

Enter pagination mode. This is helpful to manage paginated table. Pagination will handle the page progression automatically and update offset and limit parameters by his own.

page = query.paginate(2, 50)
Source
per_page

Return the number of items maximum per page.

Source
previous_page

Return current_page - 1 or nil if there is no previous page

Source
total_pages

Return the total number of pages.

Source