Skip to content

CursorSelector

Pages through an unbounded list with cursors; the base of every Item and Event selection.

Selectors are immutable: each method returns a new selector, so a configured selector can be reused. The page size is 100 until limit is called.

Fetch two consecutive pages

const selector = template.selectItems().limit(100);
const firstPage = await selector.execute();
const secondPage = await selector.cursor(firstPage.cursor).execute();

TResult

The type of each result.

cursor(value): this

Resumes the selection from a cursor returned with an earlier page.

CursorInput

The cursor, a cursor with a new page size, or undefined to start from the beginning.

this

when called on a selection that has switched to offset pagination.


execute(): Promise<CursorSelectorResult<TResult>>

Runs the selection and returns one page of results with the cursor for the next page.

Promise<CursorSelectorResult<TResult>>


first(): Promise<TResult | undefined>

Runs the selection for a single result.

Promise<TResult | undefined>

The first result, or undefined when nothing matches.


iterator(): AsyncGenerator<TResult, void, undefined>

Yields every result across all pages, fetching each page on demand at the current page size.

AsyncGenerator<TResult, void, undefined>

Walk every child of a Template

for await (const group of item.selectChildren().template(demographicGroup).iterator()) {
// ...
}

limit(value): this

Sets the page size.

number

A positive integer.

this

(error-008-invalid-selector-limit) when value is not a positive integer.