Defined in: packages/db/src/query/live/types.ts:66
Configuration interface for live query collection options
const config: LiveQueryCollectionConfig<any, any> = {
// id is optional - will auto-generate "live-query-1", "live-query-2", etc.
query: (q) => q
.from({ comment: commentsCollection })
.join(
{ user: usersCollection },
({ comment, user }) => eq(comment.user_id, user.id)
)
.where(({ comment }) => eq(comment.active, true))
.select(({ comment, user }) => ({
id: comment.id,
content: comment.content,
authorName: user.name,
})),
// getKey is optional - defaults to using stream key
getKey: (item) => item.id,
}TContext extends Context
TResult extends object = RootQueryResult<TContext>
optional autoIndex?: "eager" | "off";Defined in: packages/db/src/query/live/types.ts:117
Automatic indexing for this live-query Collection's output. Defaults to 'off'. Eager indexing requires defaultIndexType.
optional defaultIndexType?: IndexConstructor<string | number>;Defined in: packages/db/src/query/live/types.ts:123
Index implementation for this Collection's automatic and manual indexes. Setting it alone does not enable automatic indexing.
optional defaultStringCollation?: StringCollationConfig;Defined in: packages/db/src/query/live/types.ts:134
Optional compare options for string sorting. If provided, these will be used instead of inheriting from the FROM collection.
optional gcTime?: number;Defined in: packages/db/src/query/live/types.ts:111
GC time for the collection
optional getKey?: (item) => string | number;Defined in: packages/db/src/query/live/types.ts:89
Function to extract the key from result items If not provided, defaults to using the key from the D2 stream
TResult
string | number
optional id?: string;Defined in: packages/db/src/query/live/types.ts:74
Unique identifier for the collection If not provided, defaults to live-query-${number} with auto-incrementing number
optional onDelete?: DeleteMutationFn<TResult, string | number, UtilsRecord>;Defined in: packages/db/src/query/live/types.ts:101
optional onInsert?: InsertMutationFn<TResult, string | number, UtilsRecord>;Defined in: packages/db/src/query/live/types.ts:99
Optional mutation handlers
optional onUpdate?: UpdateMutationFn<TResult, string | number, UtilsRecord>;Defined in: packages/db/src/query/live/types.ts:100
query:
| ((q) => QueryBuilder<TContext> & RootObjectResultConstraint<TContext>)
| QueryBuilder<TContext> & RootObjectResultConstraint<TContext>;Defined in: packages/db/src/query/live/types.ts:79
Query builder function that defines the live query
optional schema?: undefined;Defined in: packages/db/src/query/live/types.ts:94
Optional schema for validation
optional singleResult?: true;Defined in: packages/db/src/query/live/types.ts:128
If enabled the collection will return a single object instead of an array
optional startSync?: boolean;Defined in: packages/db/src/query/live/types.ts:106
Start sync / the query immediately