InMemoryQuery
Defined in: src/persistence/query/InMemoryQuery.ts:36
Reference query implementation that walks any Journal via its
public read API. No backend-specific tag index — scans every
persistence id on each poll and filters in-process. Correct for
any journal, but only fast for the in-memory one (where the scan
is just a Map walk).
Backends that ship a “real” tag index (SQLite via the tags column,
Cassandra via secondary table) provide their own
PersistenceQuery implementation that overrides the tag
paths — see SqliteQuery and CassandraQuery.
Push delivery (#42). When the journal exposes a
JournalEventBus (journal.events), the live eventsByX queries
subscribe to it for sub-poll-interval delivery. The polling loop
stays as a fallback for cross-process journals (e.g. Cassandra)
where in-process notifications can’t reach every subscriber.
Extended by
Section titled “Extended by”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new InMemoryQuery(
journal):InMemoryQuery
Defined in: src/persistence/query/InMemoryQuery.ts:37
Parameters
Section titled “Parameters”journal
Section titled “journal”Returns
Section titled “Returns”InMemoryQuery
Methods
Section titled “Methods”currentEventsByPersistenceId()
Section titled “currentEventsByPersistenceId()”currentEventsByPersistenceId<
E>(pid,fromSeq,toSeq?):Promise<PersistentEvent<E>[]>
Defined in: src/persistence/query/InMemoryQuery.ts:41
One-shot read of every event for persistenceId whose
sequenceNr >= fromSeq (and <= toSeq if given). Resolves
once with the events known at call time.
Type Parameters
Section titled “Type Parameters”E
Parameters
Section titled “Parameters”string
fromSeq
Section titled “fromSeq”number
toSeq?
Section titled “toSeq?”number
Returns
Section titled “Returns”Promise<PersistentEvent<E>[]>
Implementation of
Section titled “Implementation of”PersistenceQuery.currentEventsByPersistenceId
currentEventsByTag()
Section titled “currentEventsByTag()”currentEventsByTag<
E>(filter,fromOffset):Promise<TaggedEvent<E>[]>
Defined in: src/persistence/query/InMemoryQuery.ts:65
One-shot read of every event matching filter whose offset is
>= fromOffset. See TagFilter for the operator semantics.
Type Parameters
Section titled “Type Parameters”E
Parameters
Section titled “Parameters”filter
Section titled “filter”fromOffset
Section titled “fromOffset”Returns
Section titled “Returns”Promise<TaggedEvent<E>[]>
Implementation of
Section titled “Implementation of”PersistenceQuery.currentEventsByTag
currentPersistenceIds()
Section titled “currentPersistenceIds()”currentPersistenceIds():
Promise<string[]>
Defined in: src/persistence/query/InMemoryQuery.ts:107
Snapshot of every persistence id known to the journal. Resolves
once. Useful for fan-out projections that subscribe to one
stream per id; pair with eventsByPersistenceId for the
continuous read.
Returns
Section titled “Returns”Promise<string[]>
Implementation of
Section titled “Implementation of”PersistenceQuery.currentPersistenceIds
eventsByPersistenceId()
Section titled “eventsByPersistenceId()”eventsByPersistenceId<
E>(pid,fromSeq,options?):AsyncIterable<PersistentEvent<E>>
Defined in: src/persistence/query/InMemoryQuery.ts:47
Live stream of every event for persistenceId whose
sequenceNr >= fromSeq. Past events are emitted first
(chronological by sequenceNr), then new events as they are
appended. The stream never completes on its own — break out of
the loop or call return() on the iterator to stop polling.
Type Parameters
Section titled “Type Parameters”E
Parameters
Section titled “Parameters”string
fromSeq
Section titled “fromSeq”number
options?
Section titled “options?”LiveQueryOptions = {}
Returns
Section titled “Returns”AsyncIterable<PersistentEvent<E>>
Implementation of
Section titled “Implementation of”PersistenceQuery.eventsByPersistenceId
eventsByTag()
Section titled “eventsByTag()”eventsByTag<
E>(filter,fromOffset,options?):AsyncIterable<TaggedEvent<E>>
Defined in: src/persistence/query/InMemoryQuery.ts:84
Live stream of every event matching filter whose offset is
>= fromOffset. Yields events ordered by (timestamp, persistenceId, sequenceNr). See Offset for offset
semantics — the stream emits the offset alongside the event so
the consumer can persist progress.
filter accepts either a single tag string (back-compat shortcut
for { all: [tag] }) or a TagFilter object that combines
all (intersect), any (union), and not (exclusion) operators.
Type Parameters
Section titled “Type Parameters”E
Parameters
Section titled “Parameters”filter
Section titled “filter”fromOffset
Section titled “fromOffset”options?
Section titled “options?”LiveQueryOptions = {}
Returns
Section titled “Returns”AsyncIterable<TaggedEvent<E>>