pagination.ts
Source: sdks/typescript/packages/sdk/src/pagination.ts. Back to the TypeScript SDK reference index.
note
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Interface Page
One page of a listing: the items and the cursor of the next page.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
items | T[] | yes | Items of the page. |
next_cursor | string | null | yes | Cursor of the next page, null on the last page. |
Interface ListParams
Query of a listing: limit, cursor and any filter.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
limit | number | no | Maximum number of items in one page. The server caps the value; read the next page with cursor. |
cursor | string | no | Opaque cursor returned as next_cursor by the previous page. Omit it to read the first page. |
Functions
collect
async collect(iter: AsyncIterable<T>, max = Infinity): Promise<T[]>
Collects every item of a paginated listing (use with care on large collections).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
iter | AsyncIterable<T> | yes | Async iterable to read, for example the result of paginate. | |
max | Infinity | no | Maximum number of items to collect (default no limit). |
Returns: Promise<T[]>. Array of the items read.