Documentation
¶
Overview ¶
Package paging parses the three pagination modes (limit, offset, keyset) and the order parameter exactly like the reference, and builds the collection links (with pagination meta nested in links).
Index ¶
Constants ¶
const ( OrderAsc = "asc" OrderDesc = "desc" )
Order values (the default is desc, the production default).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Doc ¶
type Doc struct {
Self string
Prev *string
Next *string
First *string
Last *string
// Meta is nil in cursor mode.
Meta *Meta
}
Doc is a collection's links document: the four offset links (prev/next nil at the ends) with pagination meta nested inside, or the keyset self/next pair.
type Page ¶
Page is the storage-layer list window shared by every repository: the cursor (NULL outside keyset mode), the page bounds and the direction. Fetch is the row count to read — one more than the page in cursor mode, so the row after the page answers whether a next page exists.
type Params ¶
type Params struct {
Mode Mode
Limit int
Number int
Size int
// Cursor is the keyset cursor; Valid false in the other modes.
Cursor uuid.NullUUID
Order string
}
Params is the parsed pagination of a request.
func Parse ¶
Parse reads limit, page[number], page[size], page[cursor] and order from the query. Errors are the reference's 400 documents with source.parameter set.
func (Params) SizeOrDefault ¶
SizeOrDefault answers the page size (limit mode included).