Defined in: packages/db/src/query/live-query-collection.ts:47
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,
}
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 = GetResult<TContext> & object
optional gcTime: number;
optional gcTime: number;
Defined in: packages/db/src/query/live-query-collection.ts:90
GC time for the collection
optional getKey: (item) => string | number;
optional getKey: (item) => string | number;
Defined in: packages/db/src/query/live-query-collection.ts:68
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;
optional id: string;
Defined in: packages/db/src/query/live-query-collection.ts:55
Unique identifier for the collection If not provided, defaults to live-query-${number} with auto-incrementing number
optional onDelete: DeleteMutationFn<TResult, string | number, Record<string, Fn>>;
optional onDelete: DeleteMutationFn<TResult, string | number, Record<string, Fn>>;
Defined in: packages/db/src/query/live-query-collection.ts:80
optional onInsert: InsertMutationFn<TResult, string | number, Record<string, Fn>>;
optional onInsert: InsertMutationFn<TResult, string | number, Record<string, Fn>>;
Defined in: packages/db/src/query/live-query-collection.ts:78
Optional mutation handlers
optional onUpdate: UpdateMutationFn<TResult, string | number, Record<string, Fn>>;
optional onUpdate: UpdateMutationFn<TResult, string | number, Record<string, Fn>>;
Defined in: packages/db/src/query/live-query-collection.ts:79
query:
| QueryBuilder<TContext>
| (q) => QueryBuilder<TContext>;
query:
| QueryBuilder<TContext>
| (q) => QueryBuilder<TContext>;
Defined in: packages/db/src/query/live-query-collection.ts:60
Query builder function that defines the live query
optional schema: StandardSchemaV1<unknown, unknown>;
optional schema: StandardSchemaV1<unknown, unknown>;
Defined in: packages/db/src/query/live-query-collection.ts:73
Optional schema for validation
optional startSync: boolean;
optional startSync: boolean;
Defined in: packages/db/src/query/live-query-collection.ts:85
Start sync / the query immediately
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.