InlineProjection
API reference for InlineProjection
Interface: InlineProjection<TEvent>
Section titled “Interface: InlineProjection<TEvent>”An inline projection that runs within the same request as the event append, providing read-after-write consistency.
Extends Projection<TEvent> with optional catch-up capabilities.
The SDK automatically handles batch reading and idempotent
event delivery — the projection only needs to declare where it
left off.
Example
Section titled “Example”const orderProjection: InlineProjection<OrderEvent> = { supportedEventTypes: ['order.created', 'order.shipped'], async processEvents(events) { await db.transaction(async (tx) => { for (const e of events) { await tx.insert(orders).values(toRow(e)).onConflictDoNothing(); } const last = events.at(-1); if (last) { await tx.insert(cursors) .values({ name: 'orders', position: last.globalPosition }) .onConflictDoUpdate({ set: { position: last.globalPosition } }); } }); }, async lastProcessedPosition() { const row = await db.select().from(cursors) .where(eq(cursors.name, 'orders')).get(); return row?.position ?? 0; },};Extends
Section titled “Extends”Projection<TEvent>
Type Parameters
Section titled “Type Parameters”TEvent
Section titled “TEvent”TEvent extends Event
Properties
Section titled “Properties”supportedEventTypes
Section titled “supportedEventTypes”
readonlysupportedEventTypes:EventTypeOf<TEvent>[]
List of event types this projection can handle
Inherited from
Section titled “Inherited from”Projection.supportedEventTypes
Methods
Section titled “Methods”catchUp()?
Section titled “catchUp()?”
optionalcatchUp(eventStore):Promise<void>
Full custom catch-up logic. When present, the SDK delegates
catch-up entirely to this method instead of using the automatic
batch-read → processEvents loop.
Use this escape hatch when you need optimised bulk loading
(e.g. transactional batch inserts) that processEvents alone
cannot express.
Parameters
Section titled “Parameters”eventStore
Section titled “eventStore”Returns
Section titled “Returns”Promise<void>
lastProcessedPosition()?
Section titled “lastProcessedPosition()?”
optionallastProcessedPosition():Promise<number>
Return the last globalPosition this projection has processed.
The SDK uses this to:
- Catch-up — read historical events starting from
(lastProcessedPosition + 1)and feed them throughprocessEventsin batches. - Idempotent
handleAppend— skip events whoseglobalPosition≤lastProcessedPosition.
The projection owns its own state — the SDK never persists
anything. Return 0 to replay from the beginning.
Returns
Section titled “Returns”Promise<number>
processEvents()
Section titled “processEvents()”processEvents(
events):Promise<void>
Process events through this projection
Parameters
Section titled “Parameters”events
Section titled “events”ReadEvent<TEvent>[]
Events to process
Returns
Section titled “Returns”Promise<void>