TanStackT
TanStack3mo ago
1 reply
wet-harlequin

Tanstack DB with Tanstack Table

TanStack Table + DB: Best pattern for EAV schema with dynamic columns?


Building an Airtable clone where users create custom tables with dynamic columns.

Schema: tables → columns → rows → cells (EAV pattern)
Problem: TanStack Table needs flat data, but DB is EAV

Current approach:
- Server pivots EAV → Flat (getTableFlat())
- Client uses useSuspenseQuery (React Query) for reads
- Use
useLiveQuery
+ Collections for column/row mutations (optimistic)
- Cell edits = direct mutation + full refetch (200-500ms lag)

Question: Should I:
1. Keep server-side pivot + accept lag with UX polish (toasts, loading)?
2. Migrate to client-side pivot with
useLiveQuery
(complex but optimistic)?
3. Use a different schema design entirely?

Is there a TanStack-recommended pattern for dynamic columns + EAV → flat transformation?

Stack: TanStack Start/Table/DB/Query, PostgreSQL, Drizzle ORM
Was this page helpful?