CLI
The ODB CLI connects to your database from your terminal. You can run queries, send API schemas, and execute migrations.
Key Features
- Run queries against your serverless DB
- Send API schemas to update your APIs
- Execute upgrade and downgrade migrations of queries and API schemas
Install
You can use pnpm, npm or yarn to install it.
npm install -g git+https://github.com/odbdev/cli.git
Or
pnpm install -g git+https://github.com/odbdev/cli.git
Create an account
The first step once you have installed the CLI is creating a database. Please, visit https://odb.dev and create one, or login, as it will create a database too.
When you create your database, a PRIVATE service is generated and a token is related to it. It is the token that you will need to connect to the server thought the CLI. Please, maintain it secure as it will allow the owner to interact with your database. Below, you will find more information about how to use it.
Commands
List of commands to use.
Help
Shows helpful information to work with the odb-cli.
odb help
Or
odb -h
Create
Allows to create a whole database schema and APIs. For now there is only the option to use create blog
.
odb create [TYPE]<blog>
Or
odb -c [TYPE]<blog>
Migrate
Allows upgrade and downgrade the migrations.
odb migrate [TYPE]<up | down> [FILE_NAME]<*.db | *.yaml> | [DIRECTORY]
Or
odb -m [TYPE]<up | down> [FILE_NAME]<*.db | *.yaml> | [DIRECTORY]
The migrations file format should be like the one below.
---------------------
-- Up
---------------------
The code to upgrade
---------------------
-- Down
---------------------
The code to downgrade
Run
Use it to run directly queries or API schemas. Useful for first time creation.
odb run [FILE_NAME]<*.db | *.yaml>
Or
odb -r [FILE_NAME]<*.db | *.yaml>
SQL
It enables the terminal to write queries and execute them against your database.
odb sql
Or
odb -s
Type exit or .quit to leave the SQL CLI.
Token
It is mandatory to have a token. It can be defined using the command or export or with a .odbrc file.
odb token [TOKEN] (default ODB_TOKEN env variable (ex. export ODB_TOKEN=...))
Or
odb -t [TOKEN] (default ODB_TOKEN env variable (ex. export ODB_TOKEN=...))
Config
It is used to define the config file name
odb config [FILE_NAME] (default .odbrc)
Or
odb -c [FILE_NAME] (default .odbrc)
Version
It prints the current version
odb version
Or
odb -v