Skip to content

MaterializerContextQuery

MaterializerContextQuery = {(args): readonly unknown[]; <TResult>(qb): TResult; }

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

Function signature for querying current state within a materializer.

Allows materializers to read existing data when computing mutations. Can be called with either raw SQL or a type-safe QueryBuilder.

(args): readonly unknown[]

Query with raw SQL and bind values.

ParamsObject

string

readonly unknown[]

<TResult>(qb): TResult

Query with a type-safe QueryBuilder.

TResult

QueryBuilder<TResult, any, any>

TResult

'v1.TodoUpdated': ({ id, text }, { query }) => {
const existing = query(tables.todos.select().where({ id }).first())
if (!existing) return [] // No-op if todo doesn't exist
return tables.todos.update({ text }).where({ id })
}