📄 tanstack/db/latest/docs/reference/functions/liveQueryCollectionOptions

File: liveQueryCollectionOptions.md | Updated: 11/15/2025

Source: https://tanstack.com/db/latest/docs/reference/functions/liveQueryCollectionOptions



TanStack

DB v0v0

Search...

+ K

Auto

Log In

TanStack StartRC

Docs Examples GitHub Contributors

TanStack Router

Docs Examples GitHub Contributors

TanStack Query

Docs Examples GitHub Contributors

TanStack Table

Docs Examples Github Contributors

TanStack Formnew

Docs Examples Github Contributors

TanStack DBbeta

Docs Github Contributors

TanStack Virtual

Docs Examples Github Contributors

TanStack Paceralpha

Docs Examples Github Contributors

TanStack Storealpha

Docs Examples Github Contributors

TanStack Devtoolsalpha

Docs Github Contributors

More Libraries

Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide

Documentation

Framework

React logo

React

Version

Latest

Search...

+ K

Menu

Getting Started

Guides

Collections

Frameworks

Community

API Reference

Framework

React logo

React

Version

Latest

Menu

Getting Started

Guides

Collections

Frameworks

Community

API Reference

On this page

liveQueryCollectionOptions

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

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

Returns
-------

CollectionConfigForContext<TContext, TResult, { }> & object

Collection options that can be passed to createCollection

Example
-------

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)

Edit on GitHub

createCollection

createLiveQueryCollection

Partners Become a Partner

Code RabbitCode Rabbit CloudflareCloudflare AG GridAG Grid NetlifyNetlify NeonNeon WorkOSWorkOS ClerkClerk ConvexConvex ElectricElectric SentrySentry PrismaPrisma StrapiStrapi UnkeyUnkey

scarf analytics