Skip to content

EventCursorSelector

Selects appended Events with cursor paging, filtering on their lineage and metadata rather than their payloads.

Events are immutable, so there is no write variant. The selector is available through selectEvents in a sudo or system context.

Handle events

TEvent

The type of each result.

after(date): this

Restricts results to Events created after a time.

number | Date | DateTime<boolean>

The time, as a Date, a Luxon DateTime or epoch milliseconds.

this


before(date): this

Restricts results to Events created before a time.

number | Date | DateTime<boolean>

The time, as a Date, a Luxon DateTime or epoch milliseconds.

this


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.

CursorSelector.cursor


debug(): this

Logs the resolved query when the selection runs.

this


execute(): Promise<CursorSelectorResult<TEvent>>

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

Promise<CursorSelectorResult<TEvent>>

CursorSelector.execute


first(): Promise<TEvent | undefined>

Runs the selection for a single result.

Promise<TEvent | undefined>

The first result, or undefined when nothing matches.

CursorSelector.first


itemId(id): this

Restricts results to Events targeting the given Items.

SelectorIdInput

One or more Item identifiers.

this


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

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

AsyncGenerator<TEvent, void, undefined>

Walk every child of a Template

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

CursorSelector.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.

CursorSelector.limit


parentEvent(id): this

Restricts results to Events triggered directly by the given Events.

SelectorIdInput

One or more identifiers of parent Events.

this


prn(prn): this

Restricts results to Events of the given types.

string | string[]

One or more Event PRNs, as declared in the Definition.

this


rootParent(id): this

Restricts results to Events descending from the given top-level Events of their traces.

SelectorIdInput

One or more identifiers of root Events.

this


traceId(id): this

Restricts results to Events sharing a trace.

string

The trace identifier.

this