Data and CRUD
The CLI exposes both structural commands and direct CRUD commands.
Database commands
From src/commands/db.ts, the database command group is:
db listdb create <name>db drop <name>db use <name>db current
Example:
liorandb db list
liorandb db create app
liorandb db use app
liorandb db current
Important source behavior:
db usepersists the selected database into the current profiledb dropprompts for confirmation unless--yesis passed- if you drop the profile's active database, the CLI clears that stored
databasefield
Collection commands
From src/commands/collection.ts, the collection group is:
collection listcollection create <name>collection drop <name>
You can override the active database with --db <database>.
liorandb collection list
liorandb collection create users
liorandb collection drop old-users --yes
JSON input styles
CRUD commands use helpers from src/utils/input.ts and accept JSON from:
- inline
--json --file <path>--stdin--ndjson <path>forinsert-many
That makes the CLI usable both for one-off commands and scripted pipelines.
Insert commands
liorandb insert-one users --json "{\"name\":\"Ada\",\"active\":true}"
liorandb insert-many users --file ./users.json
liorandb insert-many users --ndjson ./users.ndjson
Representative output:
{
"database": "default",
"collection": "users",
"inserted_id": "01K2EXAMPLE"
}
Find commands
The source supports:
find <collection>find-one <collection>
Shared query flags:
--db <database>--filter <json>--filter-file <path>--stdin--limit <number>--skip <number>--sort <json>--projection <json>
Example:
liorandb find users --filter "{\"active\":true}" --sort "{\"name\":1}" --limit 20
liorandb find-one users --filter "{\"email\":\"ada@example.com\"}"
Behavior worth knowing:
findstreams one record per line when output mode isndjson- in table mode,
findmaterializes records and prints them as rows find-oneprints"No document matched."in human mode when nothing is found
Update commands
The source registers:
update-one <collection>update-many <collection>
Extra update flags:
--update <json>--update-file <path>--upsert
liorandb update-one users --filter "{\"email\":\"ada@example.com\"}" --update "{\"$set\":{\"active\":false}}"
liorandb update-many users --filter "{\"active\":false}" --update "{\"$set\":{\"flagged\":true}}" --upsert
Representative output:
{
"database": "default",
"collection": "users",
"matched_count": 1,
"modified_count": 1,
"upserted_id": null
}
Delete commands
The CLI registers:
delete-one <collection>delete-many <collection>
There is one especially important safety guard in the source:
delete-manyasks for an exact collection-name confirmation when the filter matches everything, unless--yesis passed
liorandb delete-one users --filter "{\"email\":\"ada@example.com\"}"
liorandb delete-many users --filter "{}"
liorandb delete-many users --filter "{}" --yes
Aggregation
The aggregate command expects a JSON array pipeline:
liorandb aggregate users --json "[{\"$match\":{\"active\":true}},{\"$sort\":{\"name\":1}}]"
If the provided pipeline is not an array, the command throws a CLI error.
Human and machine output
These same CRUD commands can be shaped for shell automation:
liorandb find users --filter "{\"active\":true}" --output ndjson
liorandb find users --filter "{\"active\":true}" --json
liorandb insert-one users --json "{\"name\":\"Lin\"}" --quiet