Skip to main content

QueryStatsOptions

@rotorsoft/act-root


@rotorsoft/act-root / act/src / QueryStatsOptions

Type Alias: QueryStatsOptions<E>

QueryStatsOptions<E> = object

Defined in: libs/act/src/types/ports.ts:317

Options for Store.query_stats. All stat fields default to false except head, which is always returned.

Cost model: With no opt-in flags (or tail alone), each requested stat resolves via an index-backed lookup โ€” O(K) cost where K is the number of matched streams. Setting count and/or names triggers a full event scan over the matched streams (O(N) where N is total events); both share the same scan and so requesting one is the same cost as requesting both.

Type Parametersโ€‹

Eโ€‹

E extends Schemas = Schemas

Event schemas; defaults to Schemas. When the caller narrows E, exclude is type-checked against the schema's event names โ€” typos like ["TOMBSTON_EVENT"] fail at compile time.

Propertiesโ€‹

before?โ€‹

readonly optional before?: number

Defined in: libs/act/src/types/ports.ts:322

Time-travel cutoff: only consider events with id < before. Omitted = current state. Useful for "what did this stream look like at event N?" historical queries without changing the call shape. Cheap on both code paths (cheap-heads path narrows the index scan; full-scan path adds a WHERE id < ? predicate).


count?โ€‹

readonly optional count?: boolean

Defined in: libs/act/src/types/ports.ts:319

Include the total non-excluded event count per stream. Triggers full scan.


exclude?โ€‹

readonly optional exclude?: ReadonlyArray<EventName<E>>

Defined in: libs/act/src/types/ports.ts:321

Event names to skip โ€” e.g. [TOMBSTONE_EVENT, SNAP_EVENT] to ignore framework markers. Applies to all returned stats (head, tail, count, names) consistently.


names?โ€‹

readonly optional names?: boolean

Defined in: libs/act/src/types/ports.ts:320

Include a name โ†’ count map per stream. Triggers full scan (shares cost with count).


tail?โ€‹

readonly optional tail?: boolean

Defined in: libs/act/src/types/ports.ts:318

Include the earliest non-excluded event per stream. Cheap when alone (indexed); free when count/names also set (already scanning).