λORM CLI

The λORM CLI (@lambdaorm/cli) is a command line application to use λORM: it creates projects, synchronizes the databases with the schema, imports and exports data, and runs queries and scripts. Its commands run locally with a workspace (-w), and most of them can also run on a Data Gateway (-u <url>).

Installation

Install the package globally; it adds the lambdaorm command:

npm i -g @lambdaorm/cli
lambdaorm --version

It requires Node.js 20 or later. The Docker image of the Data Gateway (flaviorita/data-gateway) already includes the CLI.

Note

The unscoped lambdaorm-cli package is the old one and is no longer maintained.

Commands

Command Description
version Prints the CLI version and the @lambdaorm/lib version the project uses.
init Generates the structure of a λORM project.
build Generates the model and the repositories for the language.
schema Returns information about the schema.
push Synchronizes the databases with the model (-o writes the scripts instead).
pull Updates the schema with the structure of the databases of a stage.
fetch Shows the differences between the databases and the model; exits with code 1 when there are any.
introspect Reads and analyzes a data file and updates the schema.
incorporate Updates the schema from a data file, pushes the changes to the databases and imports the data.
drop Removes all the database objects, but not the database itself.
import Imports data from a file into the databases.
export Exports data from the databases.
execute Executes a query.
script Runs a script: several queries in one transaction.
plan Returns the execution plan of a query.
metadata Returns the metadata of a query.
parameters Returns the parameters of a query.
model Returns the model of the result of a query.
constraints Returns the constraints of a query.

lambdaorm <command> -h lists the options of a command; lambdaorm -h lists the commands.

The sync command no longer exists: it was replaced by push.

Common options

Option Short Description
workspace -w Path of the project (the folder with lambdaORM.yaml). Default: the current directory.
stage -s Name of the stage. Default: the first stage of the schema.
envfile -e Reads a file of environment variables (for example the connection strings).
output -o Output format of the result: json, beautiful, light or yaml.
url -u URL of the schema on a Data Gateway, to run the command there instead of locally.

Each command page lists the options that command accepts.

Exit code and Data Gateway

Every command exits with code 1 when it fails (from @lambdaorm/cli 1.6.3).

Commands run on a Data Gateway with -u and the URL of the schema, for example http://gateway:8080/iot/v1. When the SERVICE_TOKEN environment variable is set, it is sent as Authorization: Bearer <token> (for a gateway with bearer authentication). See also Clients.

More