Use this when you want to call db from app or test code instead of typing curl commands. It demonstrates createDbClient(), direct REST calls, and a REST batch request.
- db/users.schema.jsonc: schema-backed collection with defaults and unique email validation.
- db/settings.json: singleton document inferred from data.
- src/client-demo.js: tiny consumer script using
@async/db/client.
From the repository root, use the repo-internal CLI path:
pnpm run db -- sync --cwd ./examples/rest-client
pnpm run db -- serve --cwd ./examples/rest-clientIn another terminal:
ASYNC_DB_URL=http://127.0.0.1:7331 node ./examples/rest-client/src/client-demo.jssync writes generated schema, types, and runtime state under examples/rest-client/.db/. The demo script prints users from /db/users.json, settings from /db/settings.json, and a two-item batch result.
Leave serve running and run this from another terminal:
curl 'http://127.0.0.1:7331/db/users.json?select=id,name,email'Generated .db/ output is ignored by git and can be removed whenever you want a fresh mirror.