class

Marten::DB::Query::Paginator(M)

Inherits Marten::Template::Object / Marten::Template::CanDefineTemplateAttributes / Reference / Object

A query set paginator.

Paginators can be used to paginate the records that are targeted by a specific query set:

query_set = Post.all
query_set.paginator.page(2)

Constructors

new(queryset : Set(M), page_size : Int32)
Source

Instance methods

page(number : Int)

Returns a specific page.

This method returns the Marten::DB::Query::Page object corresponding to the passed number. If the page number does not correspond to any existing page, the latest page is returned.

Source
page!(number : Int)

Returns a specific page.

This method returns the Marten::DB::Query::Page object corresponding to the passed number. If the page number does not correspond to any existing page, a Marten::DB::Query::Paginator::EmptyPageError exception is raised.

Source
page_size
Source
pages_count

Returns the number of pages.

Source
queryset
Source
total_count

Returns the total number of records in the queryset, without applying pagination.

Source

Nested types