@mimik/pagination-helper
v3.2.1
Published
Pagination helper for microservices
Readme
pagination-helper
Example
import { setUrlOnPaginatedResult, validatePaginationOptions } from '@mimik/pagination-helper';Example
import paginationHelper from '@mimik/pagination-helper';pagination-helper~setUrlOnPaginatedResult(data, options, basePath, serverSettings) ⇒ object
The response is an object of the following format:
{
"data": "an array of items result of paginated search.",
"count": "a number. Present if provided.",
"nextPageUrl": "a URL to point to the next page. Present if data is non-empty, lastRecordId is provided, and the data length is greater than or equal to the effective pageSize."
}Kind: inner method of pagination-helper
Returns: object - The response object with data (array), optional count (number), and optional nextPageUrl (string). The nextPageUrl is present only when data is non-empty, lastRecordId is provided, and data.length >= pageSize (an effective pageSize, where a pageSize query already present in basePath takes precedence over options.pageSize).
Category: sync
Requires: module:@mimik/address-helper
| Param | Type | Description |
| --- | --- | --- |
| data | array | data to include in the response. |
| options | object | options to setup the response. Includes count, lastRecordId and pageSize. |
| basePath | string | URL base path in order to build the nextPageUrl. Can include queries. |
| serverSettings | object | Server settings to build the nextPageUrl. |
pagination-helper~validatePaginationOptions(options) ⇒ boolean
Validating the pagination params.
Kind: inner method of pagination-helper
Returns: boolean - true.
Category: sync
Throws:
- Error A rich error (an
Errorinstance) with statusCode400.
Requires: module:@mimik/response-helper
| Param | Type | Description |
| --- | --- | --- |
| options | object | options to validate. Includes startAfter and pageSize. |
