Files
b27694b1d4 docs: add TanStack DB reference page (#51086)
## Problem

`supabase/tanstack-db` (a frontend data layer syncing TanStack DB
collections with Postgres via Supabase) has no reference documentation
on supabase.com/docs.

## Solution

Adds a new `/reference/tanstack-db` SDK reference page documenting
`supabaseCollectionOptions()`, `queryOnce()`, and live-query/mutation
usage. Since the package has no TypeDoc pipeline (unlike
`middleware`/`server`), it uses the legacy hand-written YAML spec
pattern already used for Python, Swift, C#, and Dart v1
(`apps/docs/spec/supabase_tanstack_db_v1.yml`), wired into
`navigation.references.ts` and the sidebar/breadcrumb constants the same
way as the existing `middleware` entry. Content is sourced from the
public `supabase/tanstack-db` README and source, since there's no
internal ticket for this.

## Review instructions

1. Run `pnpm run codegen:references:legacy` in `apps/docs` and confirm
`features/docs/generated/tanstack_db.v1.*.json` are generated.
2. Start local Supabase (`pnpm supabase start`) and `pnpm dev:docs`,
then visit `/docs/reference/tanstack_db` and confirm the sidebar entry
and content render.

## Checklist

- [ ] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Tiago Antunes <tiagoantunespt@gmail.com>
2026-10-28 22:10:43 +01:00

27 lines
1.5 KiB
JSON

{
"title": "queryOnce()",
"description": "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.",
"params": [
{
"name": "callback",
"isOptional": false,
"type": "(q: InitialQueryBuilder) => QueryBuilder",
"description": "A query builder function describing the query to run once."
},
{
"name": "supabase",
"isOptional": false,
"type": "SupabaseClient",
"description": "The Supabase client instance to run the query against."
}
],
"notes": "- Aggregates use PostgREST aggregate functions, which are disabled by default. Enable them with `alter role authenticator set pgrst.db_aggregates_enabled = 'true';` followed by `notify pgrst, 'reload config';`.\n- Queries with aggregates run as a single PostgREST request and require fully pushable `where` expressions. Unsupported filters throw instead of aggregating over unfiltered rows.\n- `groupBy` and `having` aren't supported.",
"examples": [
{
"id": "query-once-example",
"name": "Run a one-time query",
"code": "```tsx\nimport { eq } from '@tanstack/react-db'\nimport { queryOnce } from '@supabase-labs/tanstack-db'\n\nconst completed = await queryOnce(\n (q) => q.from({ todo: todos }).where(({ todo }) => eq(todo.completed, true)),\n supabase\n)\n```"
}
]
}