Trait
Defined in: packages/@livestore/common/dist/schema/state/sqlite/client-document-def.d.ts:94
Type Parameters
Section titled “Type Parameters”TName extends string
TType
TEncoded
Section titled “TEncoded”TEncoded
TOptions
Section titled “TOptions”TOptions extends ClientDocumentTableOptions<TType>
Properties
Section titled “Properties”[ClientDocumentTableDefSymbol]
Section titled “[ClientDocumentTableDefSymbol]”
readonly[ClientDocumentTableDefSymbol]:object
Defined in: packages/@livestore/common/dist/schema/state/sqlite/client-document-def.d.ts:165
derived
Section titled “derived”
readonlyderived:object
derived.setEventDef
Section titled “derived.setEventDef”
readonlysetEventDef:SetEventDef<TName,TType,TOptions>
derived.setMaterializer
Section titled “derived.setMaterializer”
readonlysetMaterializer:Materializer<SetEventDef<TName,TType,TOptions>>
options
Section titled “options”
readonlyoptions:TOptions
default
Section titled “default”
readonlydefault:TOptions["default"]
Defined in: packages/@livestore/common/dist/schema/state/sqlite/client-document-def.d.ts:164
readonlyget:MakeGetQueryBuilder<TName,TType,TOptions>
Defined in: packages/@livestore/common/dist/schema/state/sqlite/client-document-def.d.ts:123
Get the current value of the client document table.
Example
Section titled “Example”const someDocumentTable = State.SQLite.clientDocument({ name: 'SomeDocumentTable', schema: Schema.Struct({ someField: Schema.String, }), default: { value: { someField: 'some-value' } },})
const value$ = queryDb(someDocumentTable.get('some-id'))
// When you've set a default id, you can omit the id argument
const uiState = State.SQLite.clientDocument({ name: 'UiState', schema: Schema.Struct({ someField: Schema.String, }), default: { id: SessionIdSymbol, value: { someField: 'some-value' } },})
const value$ = queryDb(uiState.get())
readonlyset:SetEventDefLike<TName,TType,TOptions>
Defined in: packages/@livestore/common/dist/schema/state/sqlite/client-document-def.d.ts:161
Derived event definition for setting the value of the client document table. If the document doesn’t exist yet, the first .set event will create it.
Examples
Section titled “Examples”const someDocumentTable = State.SQLite.clientDocument({ name: 'SomeDocumentTable', schema: Schema.Struct({ someField: Schema.String, someOtherField: Schema.String, }), default: { value: { someField: 'some-default-value', someOtherField: 'some-other-default-value' } },})
const setEventDef = store.commit(someDocumentTable.set({ someField: 'explicit-value' }, 'some-id'))// Will commit an event with the following payload:// { id: 'some-id', value: { someField: 'explicit-value', someOtherField: 'some-other-default-value' } }Similar to .get, you can omit the id argument if you’ve set a default id.
const uiState = State.SQLite.clientDocument({ name: 'UiState', schema: Schema.Struct({ someField: Schema.String }), default: { id: SessionIdSymbol, value: { someField: 'some-default-value' } },})
const setEventDef = store.commit(uiState.set({ someField: 'explicit-value' }))// Will commit an event with the following payload:// { id: '...', value: { someField: 'explicit-value' } }// ^^^// Automatically replaced with the client session id
readonlyValue:TType
Defined in: packages/@livestore/common/dist/schema/state/sqlite/client-document-def.d.ts:162
valueSchema
Section titled “valueSchema”
readonlyvalueSchema:Schema<TType,TEncoded>
Defined in: packages/@livestore/common/dist/schema/state/sqlite/client-document-def.d.ts:163