Runs a single, non-reactive query against a collection. Filters, ordering, limits, and joins are pushed to PostgREST where possible. Aggregates like count and sum run on the server. Other operations, like distinct and computed fields, are applied client-side.
alter role authenticator set pgrst.db_aggregates_enabled = 'true'; followed by notify pgrst, 'reload config';.where expressions. Unsupported filters throw instead of aggregating over unfiltered rows.groupBy and having aren't supported.A query builder function describing the query to run once.
The Supabase client instance to run the query against.
import { eq } from '@tanstack/react-db'
import { queryOnce } from '@supabase-labs/tanstack-db'
const completed = await queryOnce(
(q) => q.from({ todo: todos }).where(({ todo }) => eq(todo.completed, true)),
supabase
)