Skip to main content

Module pagination

Module pagination 

Source
Expand description

Page-number pagination over HTTP: PageParams reads and checks ?page=N&per_page=M, and Page is the response body.

Page is built from the ORM’s orm::Page (QuerySet::paginate is unchanged: one COUNT and one fetch), so total and items come from two statements. Without a transaction that pins a snapshot, rows written between them can make total and the items disagree, and an unordered queryset can return a row on two pages or on none; order by a unique key for stable pages.

CursorParams and CursorPage page by cursor instead (?after= or ?before= and ?limit=): one statement, no total, and rows that exist for the whole iteration are returned exactly once.

Structs§

CursorPage
One page of T as a response body, with the cursors to its neighbours and no total.
CursorParams
?after=TOKEN or ?before=TOKEN, and ?limit=N from 1 to MAX, DEFAULT when absent.
Page
One page of T as a response body.
PageParams
?page=N&per_page=M: a 1-based page and a page size from 1 to MAX, DEFAULT when absent.

Type Aliases§

Fetched
The result of PageParams::fetch.