定义于:packages/db/src/query/live-query-collection.ts:47
实时查询集合选项的配置接口
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 继承 object = GetResult<TContext> & object
optional gcTime: number;
optional gcTime: number;
定义于:packages/db/src/query/live-query-collection.ts:90
集合的 GC 时间
optional getKey: (item) => string | number;
optional getKey: (item) => string | number;
定义于:packages/db/src/query/live-query-collection.ts:68
用于从结果项中提取键的函数。如果未提供,则默认使用 D2 流中的键。
TResult
string | number
optional id: string;
optional id: string;
定义于:packages/db/src/query/live-query-collection.ts:55
集合的唯一标识符。如果未提供,则默认为带自动递增数字的 live-query-${number}。
optional onDelete: DeleteMutationFn<TResult, string | number, Record<string, Fn>>;
optional onDelete: DeleteMutationFn<TResult, string | number, Record<string, Fn>>;
定义于: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>>;
定义于:packages/db/src/query/live-query-collection.ts:78
可选的 mutation 处理程序
optional onUpdate: UpdateMutationFn<TResult, string | number, Record<string, Fn>>;
optional onUpdate: UpdateMutationFn<TResult, string | number, Record<string, Fn>>;
定义于:packages/db/src/query/live-query-collection.ts:79
query:
| QueryBuilder<TContext>
| (q) => QueryBuilder<TContext>;
query:
| QueryBuilder<TContext>
| (q) => QueryBuilder<TContext>;
定义于:packages/db/src/query/live-query-collection.ts:60
定义实时查询的查询构建器函数
optional schema: StandardSchemaV1<unknown, unknown>;
optional schema: StandardSchemaV1<unknown, unknown>;
定义于:packages/db/src/query/live-query-collection.ts:73
用于验证的可选 schema
optional startSync: boolean;
optional startSync: boolean;
定义于:packages/db/src/query/live-query-collection.ts:85
立即开始同步/查询
您的每周 JavaScript 资讯。每周一免费发送给超过 10 万开发者。