NEDB Docs / Reference / CLI Tools

Three CLIs ship with the engine. Two operate on store directories offline — no daemon, no port; one opens a store and speaks both halves of the query language.

nedb-cli — offline operations

cargo install nedb-engine   # ships nedb-cli + nedb-inspector

nedb-cli head ./data         # the Merkle tip
nedb-cli status ./data       # objects, segments, scan state
nedb-cli verify ./data       # walk the chain
nedb-cli get ./data <coll> <id>
nedb-cli scan ./data         # force the integrity scan
nedb-cli flush ./data
nedb-cli repair ./data       # rebuild the derivable id index
nedb-cli export ./data

repair exists because every object carries its own coll/id/seq: the index is fully derivable, nothing is invented — it rebuilds entries, verifies nodes, flushes, and reports exactly what it did.

nesql — the language CLI

nesql --db ./store query "SELECT who, total FROM orders ORDER BY total DESC"
nesql --db ./store query "FROM orders WHERE total > 150"
nesql --db ./store root verify
nesql --db ./store constitution

Speaks both neSQL statement forms through one router (the same nedb_engine::neql::route the daemon uses). --json emits exactly one JSON object on stdout with diagnostics on stderr — a pipe stays clean. Exit codes: 0 success · 1 failure · 2 usage · 3 could not determine (pruned history) · 4 not found · 5 unsupported. 3 is the one that matters: a pruned store is not a corrupt one, and root verify reports stored record and recomputation as two independent facts — only recomputation DIFFERS is an alarm.

Beyond query: status, log, inspect (collection / document / sequence / persisted root — named by kind, because a bare 42 could be either and the CLI refuses to pick), diff, immutable tag, branch, merge with first-class conflicts, and grammar/constitution — digests of the command surface and the engine's guarantees, comparable across builds, so a deployment can prove it agrees with the binary that shipped.

nedb-inspector

A deterministic checker (no regex, no LLM) that warns when a durable open lacks flush-on-exit wiring — the exact gap that made crash-lost-writes possible in embedded use. See Durability.

Shell tooling for Cast

. ./scripts/nedb.sh      # bash / zsh / Git Bash
nedb-dbs                  # which databases exist
nedb-use shop             # pick one
cast "orders over 100"    # plan only — nothing runs
cast -x "orders over 100" # plan AND execute

NEDB=http://host:7070 points the shell helpers at a remote daemon. Prompts are JSON-escaped, so quotes and apostrophes are safe.