CLI Usage
The UnrealORM CLI is @unreal-orm/cli, usually run through bunx, npx, or pnpm dlx as unreal.
Install
Section titled “Install”bun add -D @unreal-orm/cliCommands
Section titled “Commands”| Command | Purpose |
|---|---|
unreal init |
Scaffold unreal.config.json, unreal/surreal.ts, and sample models. |
unreal push |
Apply TypeScript models to the database. |
unreal pull |
Introspect the database and generate TypeScript models. |
unreal diff |
Compare local models with the database schema. |
unreal mermaid |
Generate a Mermaid ERD from code, the database, or a .surql file. |
unreal view |
Browse records interactively. |
unreal docs |
Open the docs or generate context files. |
unreal github |
Open the repository on GitHub. |
Connection resolution
Section titled “Connection resolution”Every database command resolves the connection in this order:
- CLI flags —
--url,-u/--username,-p/--password,-n/--namespace,-d/--database,--auth-level,--embedded unreal/surreal.ts— auto-loaded from the configuredunreal/folder- Interactive prompt — if no flags and no
surreal.tsare found
Fully automated push
Section titled “Fully automated push”bunx unreal push \ --url ws://localhost:8000 \ -u root -p secret \ -n production -d myapp \ --auth-level root \ -yConnection from a file
Section titled “Connection from a file”# Use the connection defined in unreal/surreal.tsbunx unreal pushDiff options
Section titled “Diff options”# Show detailed field-level changesbunx unreal diff --detailed
# Use embedded in-memory SurrealDBbunx unreal diff --embedded mem://Embedded mode
Section titled “Embedded mode”For quick tests without a server:
bunx unreal push --embedded mem:// -yUse --embedded with a file path for disk persistence:
bunx unreal push --embedded file:/tmp/mydb -yProject layout expected by the CLI
Section titled “Project layout expected by the CLI”my-project/├── unreal.config.json├── unreal/│ ├── surreal.ts│ └── tables/└── package.jsonunreal.config.json only contains the path to the unreal/ folder:
{ "$schema": "./node_modules/unreal-orm/schema.json", "path": "./unreal"}For per-command details, see the generated CLI Reference.