Examples
Each example is a self-contained project that applies a todos schema with the
standalone db-x CLI. They all follow the same shape: schema.tsx holds a
reusable component, dbx.tsx wires the connection around it.
DB-X is an early prototype. Do not point it at a database you care about.
Runnable today
| Example | Library | Engine page | Needs |
|---|---|---|---|
examples/postgres | @db-x/postgres-library | PostgreSQL | psql, Docker |
examples/sqlite | @db-x/sqlite-library | SQLite | sqlite3 |
examples/mongodb | @db-x/mongodb-library | MongoDB | mongosh, Docker |
examples/cockroachdb | @db-x/postgres-library | CockroachDB | psql, Docker |
examples/supabase | @db-x/postgres-library | Supabase | Supabase CLI, Docker |
examples/sqlite
is the quickest start: the file is the database, so there is no server, no
credentials and no container.
Engine support at a glance
| Engine | Snapshot driver | Drift detection | Notable limit |
|---|---|---|---|
| PostgreSQL | pg_dump (schema or full) | yes | — |
| SQLite | file copy (always full) | yes | no ALTER COLUMN — needs a table rebuild (#56) |
| MongoDB | mongodump | yes | validator tightening detected heuristically |
| CockroachDB | none | yes | pg_dump unsupported, so no rollback (#85) |
| Supabase | pg_dump (schema or full) | yes | auth.users and RLS are raw SQL, not components |
Not built yet
examples/ also holds README-only placeholders for CouchDB, DuckDB, MySQL,
Oracle and SQL Server. They describe the intended shape and link to the issue
tracking the library each would need — there is nothing to run yet.
The loop
Every runnable example supports the same cycle:
pnpm install && pnpm build # from the repo root, once
cd examples/<engine>
pnpm preview # render, diff, print the exact statements
pnpm apply --yes # execute them, persist state to .dbx/
pnpm apply --yes --allow-destructive # snapshot first, then apply
pnpm restore --yes # roll back to that snapshot
pnpm destroy # tear it down in reverse order
preview renders and diffs offline — it never connects to a database. apply
refuses a destructive change unless you pass --allow-destructive, and refuses
again if it cannot capture a snapshot first, so there is always something to
roll back to. CockroachDB is the one target where that second gate never opens.
Start with the Quickstart (Docker), then read Time Machine for how snapshots and rollback work.