toPaginated
utils
Source Code | DocumentationEnsures 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.
ts
import { toPaginated } from 'feathers-utils/utils';Example
ts
import { toPaginated } from 'feathers-utils/utils'
const paginated = toPaginated([{ id: 1 }, { id: 2 }])
// => { total: 2, limit: 2, skip: 0, data: [{ id: 1 }, { id: 2 }] }Type declaration
Show Type Declarations
ts
/**
* 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.
*
* @example
* ```ts
*
*
* const paginated = toPaginated([{ id: 1 }, { id: 2 }])
* // => { total: 2, limit: 2, skip: 0, data: [{ id: 1 }, { id: 2 }] }
* ```
*
* @see https://utils.feathersjs.com/utils/to-paginated.html
*/
export declare function toPaginated<R>(result: R[] | Paginated<R>): Paginated<R>| Argument | Type | Description |
|---|---|---|
| result | R[] | Paginated<R> |
