File: liveQueryCollectionOptions.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
React
Version
Latest
Search...
+ K
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
Framework
React
Version
Latest
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
On this page
Copy Markdown
Function: liveQueryCollectionOptions()
======================================
ts
function liveQueryCollectionOptions<TContext, TResult>(config): CollectionConfigForContext<TContext, TResult, {
}> & object;
function liveQueryCollectionOptions<TContext, TResult>(config): CollectionConfigForContext<TContext, TResult, {
}> & object;
Defined in: packages/db/src/query/live-query-collection.ts:62
Creates live query collection options for use with createCollection
Type Parameters
---------------
### TContext
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] }
Parameters
----------
### config
LiveQueryCollectionConfig <TContext, TResult>
Configuration options for the live query collection
CollectionConfigForContext<TContext, TResult, { }> & object
Collection options that can be passed to createCollection
typescript
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)
