function liveQueryCollectionOptions<TContext, TResult>(config): CollectionConfig<TResult>
function liveQueryCollectionOptions<TContext, TResult>(config): CollectionConfig<TResult>
定义于: packages/db/src/query/live-query-collection.ts:117
为 createCollection 使用创建 live query collection 选项
• TContext extends Context
• TResult extends object = { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }
LiveQueryCollectionConfig<TContext, TResult>
live query collection 的配置选项
CollectionConfig<TResult>
可以传递给 createCollection 的 collection 选项
const options = liveQueryCollectionOptions({
// id is optional - will auto-generate if not provided
query: (q) => q
.from({ post: postsCollection })
.where(({ post }) => eq(post.published, true))
.select(({ post }) => ({
id: post.id,
title: post.title,
content: post.content,
})),
// getKey is optional - will use stream key if not provided
})
const collection = createCollection(options)
const options = liveQueryCollectionOptions({
// id is optional - will auto-generate if not provided
query: (q) => q
.from({ post: postsCollection })
.where(({ post }) => eq(post.published, true))
.select(({ post }) => ({
id: post.id,
title: post.title,
content: post.content,
})),
// getKey is optional - will use stream key if not provided
})
const collection = createCollection(options)
您的每周 JavaScript 资讯。每周一免费发送给超过 10 万开发者。