31 The command line tool
relatude is the command line tool for Relatude.DB. It creates new applications, and it works on an
existing database and datamodel from the outside, without your application running. Use it to look
at the model, run a query, generate model code, check a model before you wire it up, and do routine
maintenance. Its output is plain text or JSON, so scripts and coding agents can use it too.
dotnet tool install -g Relatude.DB.Tool # install
dotnet tool update -g Relatude.DB.Tool # update to the latest version
relatude helpThe tool needs the .NET 10 runtime. It binds your model types to its own copy of Relatude.DB, so keep the tool on the same version as the Relatude.DB packages your project uses.
- The commands — relatude help <command> describes one command and its options. relatude help all prints the whole reference at once.
- A typical session — Create a content website, give it a model, and look at it from the outside:
- Finding the database and the model — Most commands start from the database's relatude.db.json (see section 12). The tool looks for relatude.settings/relatude.db.json in the current folder and in the folders above it. You can also point at it:
- Creating a project — relatude new MyApp writes a complete application into ./MyApp. It writes source only and builds nothing. --projecttype picks the kind of application:
- Undoing an experiment — timestamp and revert run the workflow of section 16.1 from the outside. Take the head of the log before you change anything, and put the database back afterwards:
- Running queries — query takes the text form of the query API, which is also what the HTTP API and the admin UI send. It reads like the typed API of Part III: a node type followed by method calls. Pass values with --param name=value and…
- Things worth knowing — Stop the application first. info, query, insert, delete, timestamp, revert and maintenance open the database, and its log file has a single writer. If a running application holds it, the command fails and says so. The…