Skip to content

pagination

Concerns $limit/$skip or the paginated result shape.

NameCategoryDescription
disablePagination
hooks

Disables pagination when query.$limit is -1 or '-1'. Removes the $limit from the query and sets params.paginate = false. Must be used as a before or around hook on the find method.

getPaginate
utils

Resolves the active pagination options for the current hook context. Checks (in order): context.params.paginate, service.options.paginate, and context.params.adapter.paginate. Returns undefined if pagination is disabled.

getResultIsArray
utils

Normalizes context.result (or context.dispatch) into an array for uniform processing. Handles paginated results by extracting the data array. Returns { result, isArray, key } where key indicates whether 'result' or 'dispatch' was used.

mutateResult
utils

Applies a transformer function to each item in context.result (and optionally context.dispatch). Handles paginated results, single items, and arrays transparently. Use the dispatch option to control whether result, dispatch, or both are transformed.

toPaginated
utils

Ensures a result is in Feathers paginated format ({ total, limit, skip, data }). If the input is already paginated, it is returned as-is. If it is a plain array, it is wrapped in a paginated object with total and limit set to the array length.

unpaginate
utils

Extracts the items from a find result that may or may not be paginated. A plain array is returned as-is, a paginated result yields its data, and undefined/null yields an empty array - so a find can be consumed without knowing whether pagination is enabled for the service or disabled via params.paginate: false.

This is the lossy counterpart to toPaginated: total, limit and skip are dropped, so unpaginate(toPaginated(x)) round-trips but the reverse does not. The returned array MUST be treated as read-only - it is the input array or the paginated result's data, never a copy.

isPaginated
predicates

Checks if the current find operation is paginated by inspecting params.paginate and the service's pagination options via getPaginate. Returns false for all methods other than find or when pagination is disabled.

See all tags for the full vocabulary.

Released under the MIT License.