Use this when local fixtures need related records but you still want plain ids in JSON. It demonstrates to-one relation metadata, explicit REST expand, and nested select.
- db/users.schema.jsonc: target collection.
- db/posts.schema.jsonc:
authorIddeclares a relation tousers.id. - db.config.mjs: default mirror setup using
defineConfig.
From the repository root, use the repo-internal CLI path:
npm run db -- sync --cwd ./examples/relations
npm run db -- serve --cwd ./examples/relationsOpen the viewer:
http://127.0.0.1:7331/__dbThe viewer lists posts and users. The posts schema shows an author relation derived from authorId.
Leave serve running and run this from another terminal:
curl 'http://127.0.0.1:7331/db/posts.json?expand=author&select=id,title,author.name'Relation expansion is intentionally explicit and depth 1 in this version.
Generated .db/ output is ignored by git and can be removed whenever you want a fresh mirror.