Skip to content

Materializer

Materializer<TEventDef> = (event, context) => SingleOrReadonlyArray<MaterializerResult>

Defined in: packages/@livestore/common/dist/schema/EventDef/materializer.d.ts:85

Function type for transforming an event into database mutations.

Materializers are the bridge between events and SQLite state. They receive the decoded event arguments and return SQL operations to execute.

TEventDef extends AnyWithoutFn = AnyWithoutFn

TEventDef["schema"]["Type"]

EventDefFacts

Current facts state (experimental).

Decoded

Full event metadata including clientId, sessionId, sequence numbers.

TEventDef

The event definition being materialized.

MaterializerContextQuery

Function to query current database state.

SingleOrReadonlyArray<MaterializerResult>

const todoCreatedMaterializer: Materializer<typeof todoCreated> =
({ id, text }) => tables.todos.insert({ id, text, completed: false })