Function: paginate()
function paginate<T, Cursor>(fetchPage, initialCursor): AsyncGenerator<T>;
Defined in: src/listing.ts:41
Yield records from a cursor-based page fetcher until it has no next cursor.
Type Parameters
| Type Parameter |
|---|
T |
Cursor |
Parameters
| Parameter | Type |
|---|---|
fetchPage | (cursor) => Promise<PaginationPage<T, Cursor>> |
initialCursor | Cursor |
Returns
AsyncGenerator<T>
Example
import { collectAll, paginate } from '@cdot65/prisma-airs-sdk';
const records = await collectAll(paginate(async (offset: number) => {
const page = await api.list({ offset, limit: 100 });
return { items: page.items, next: page.next_offset };
}, 0));