MaterializerContextQuery
MaterializerContextQuery = {(
args): readonlyunknown[]; <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.
Call Signature
Section titled “Call Signature”(
args): readonlyunknown[]
Query with raw SQL and bind values.
Parameters
Section titled “Parameters”bindValues
Section titled “bindValues”ParamsObject
string
Returns
Section titled “Returns”readonly unknown[]
Call Signature
Section titled “Call Signature”<
TResult>(qb):TResult
Query with a type-safe QueryBuilder.
Type Parameters
Section titled “Type Parameters”TResult
Section titled “TResult”TResult
Parameters
Section titled “Parameters”QueryBuilder<TResult, any, any>
Returns
Section titled “Returns”TResult
Example
Section titled “Example”'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 })}