Use this when product, customer, or spreadsheet-like data starts as CSV. db scans the header row, infers field shapes, generates types, and mirrors the rows into JSON runtime state.
- db/customers.csv: source CSV fixture.
- db.config.mjs: default mirror setup using
defineConfig.
From the repository root, use the repo-internal CLI path:
npm run db -- sync --cwd ./examples/csv
npm run db -- serve --cwd ./examples/csvOpen the viewer:
http://127.0.0.1:7331/__dbsync writes .db/state/customers.json. When db/customers.csv changes, the source hash changes and the JSON store refreshes from CSV.
Leave serve running and run this from another terminal:
curl 'http://127.0.0.1:7331/db/customers.json?select=id,name,email'Generated .db/ output is ignored by git and can be removed whenever you want fresh runtime state.