Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Relations Example

What This Teaches

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.

Files To Inspect

Run It

From the repository root, use the repo-internal CLI path:

npm run db -- sync --cwd ./examples/relations
npm run db -- serve --cwd ./examples/relations

Open the viewer:

http://127.0.0.1:7331/__db

Expected Result

The viewer lists posts and users. The posts schema shows an author relation derived from authorId.

REST Request To Try

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.

Features To Notice

Cleanup

Generated .db/ output is ignored by git and can be removed whenever you want a fresh mirror.

More Docs