CassandraQuery
Defined in: src/persistence/query/CassandraQuery.ts:46
Cassandra/Scylla query. By default, inherits the journal-walking
currentEventsByTag from InMemoryQuery — correct for any
volume but only fast for small-to-medium event corpora because the
default Cassandra schema has no secondary index on the tags
column.
When the journal was constructed with useTagIndex: true, append
dual-writes every (event, tag) pair into an events_by_tag side
table partitioned by (tag) and ordered by (timestamp, persistence_id, sequence_nr). This class overrides
currentEventsByTag to walk that side table — a single
tag-partition scan instead of a full client-side journal sweep
(#44).
Multi-tag filters. The TagFilter operators (all / any /
not, see TagFilter) translate into the side-table query
the same way SqliteQuery does:
allnon-empty → walk the side-table partition forall[0], JS-refine the rest of the filter against the per-rowtagsset carried in the side table. Bounded scan even when the final result is the intersection of several tags.anynon-empty (noall) → walk one partition peranytag and merge by(persistence_id, sequence_nr). N partition scans, sequential, JS-refinesnot.- Only
not(or fully empty) → fall back to the inherited journal scan; only-notqueries don’t have a selective tag to seed the index walk anyway.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CassandraQuery(
cassandra):CassandraQuery
Defined in: src/persistence/query/CassandraQuery.ts:50
Parameters
Section titled “Parameters”cassandra
Section titled “cassandra”Returns
Section titled “Returns”CassandraQuery
Overrides
Section titled “Overrides”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>[]>
Inherited from
Section titled “Inherited from”InMemoryQuery.currentEventsByPersistenceId
currentEventsByTag()
Section titled “currentEventsByTag()”currentEventsByTag<
E>(filter,fromOffset):Promise<TaggedEvent<E>[]>
Defined in: src/persistence/query/CassandraQuery.ts:55
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>[]>
Overrides
Section titled “Overrides”InMemoryQuery.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[]>
Inherited from
Section titled “Inherited from”InMemoryQuery.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>>
Inherited from
Section titled “Inherited from”InMemoryQuery.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>>