1.0.0
Koa Middleware function that reads pagination parameters from the query string, and populate ctx.state.pageable
with a Pageable instance.
(Context)
Context associated with the Koa middleware function
Promise
:
Represents the configuration for a page of elements. Created by the middleware based on the request query parameters
(number)
The page to be returned
(number)
The number of elements to be returned
(boolean)
The format to return the results in.
If true and the type of the content being returned supports it (has an
id
property), the result will contain a
(potentially ordered, based on
sort
) list of
ids
and a corresponding map of
{id: content item}
, else content
returned as a simple array. Default value is false.
If true and the type of the content being returned supports it (has an id
property), the resulting Page
will be of type IndexedPage and will contain a
(potentially ordered, based on sort
) list of ids
and a corresponding map of {id : content item}
, else the
page will be of type {@ArrayPage} and content will be returned as a simple array.
Type: boolean
Sort options that should be applied to returned data set. Represents an iterable list of ordered properties.
Provides ability to execute Sort.forEach(...) and iterate over its contained list of Orders.
(function (property: string, direction: DirectionType): any)
Function invoked with and provided with each
Order
's (property, direction) pair as
arguments
Enumeration of sort directions
Pairing of a property and a Direction. Represents a single property that should be ordered as part of a Sort
(string)
The property to be ordered
Type: DirectionType
"Base class" for container for content being returned.
(number)
The total number of elements in the data set
Represents a sublist of a list of objects. Provides details about the total list, including whether there is more data available.
Extends Page
(Array<T>)
The content to be returned
(number)
The total number of elements in the data set
A page that has its content normalized into an array of ids and a corresponding map of {id : content item }
Extends Page
(Array<I>)
Array of content ids
({})
Map of Id to Content Items
(number)
The total number of elements in the data set
Map of {id : content item}
Type: {}
Returns a new IndexedPage created by running each element of index
through iteratee
(function (T): R)
Method to transform content elements
IndexedPage<I, R>
:
Transformed
IndexedPage
Page type that can be serialized to json as either an {@ArrayPage} or {@IndexedPage}.
In order to achieve this, all elements in the content array must have an id
property.
Then, upon serialization, if the indexed
value is true, the content is grouped by id
to obtain the map of {id: content item}
and written as an IndexedPage, else it is written as an ArrayPage
Extends Page
(Array<T>)
The content to be returned
(number)
The total number of elements in the data set
Returns a new IndexablePage created by running each element of content
through iteratee
(function (T): R)
Method to transform content elements
IndexablePage<I, R>
:
Transformed
IndexablePage
Json Serizliation that checks indexed
property, and returns an IndexedPage if true, else
ArrayPage
Page
:
Base Class for error types thrown by Koa Paginate.
Extends Error
(string)
The human-readable message describing the error
HTTP Status code to be returned, 400
Error type thrown when parsing Pagination parameters fails
Extends KoaPageableError
(string)
The human-readable message describing the error
Error type thrown when an invalid Sort Direction is provided on the request.
Extends KoaPageableError
Flow type for Direction enum
Type: $Keys<any>