mongodb

mongodb connects to MongoDB, inspects collections, indexes and documents, performs focused changes, exports JSON and runs native command documents.

DatabaseVersion 1.1.3Stable
lil-terminal

Overview

Use mongodb for collections and documents with the same compact database vocabulary: hidden-password connection, indexes, previews, focused edits, JSON export, native command documents and logical backups.

Documents and collections

MongoDB stores BSON-like documents in collections rather than rows in fixed SQL tables. Documents in one collection may differ in shape, but “flexible schema” does not mean structure is irrelevant: applications still need stable field meanings, validation and indexes. Use the compact surface for common inspection and mutations, and native command documents after : when MongoDB-specific queries or operators are needed.

Syntax

lil-terminal
mongodb [options] · mongodb : <json-command>

Reference

mongodb

show the current MongoDB connection

mongodb -c <host|uri> [user] [database] [-p <port>] [-n] [-m [name]]

connect; password is requested separately when a user is supplied unless -n is used

-use <database>

select another database

-l

list databases

-t

list collections

-s <collection>

show collection indexes

-n <collection> [documents]

preview documents

-f <collection> <field> <value> [documents]

find documents by one field

-o <collection> [file] [-f]

export documents as JSON

-a <collection> : <json>

insert one document

-w <collection> <field> <value> : <json>

update matching documents

-d <collection> <field> <value>

delete matching documents

-m [name]

save the current connection in .lil.key; default name is the database

-M <name>

remove a saved connection

-k [name]

list saved connections or inspect one without showing its password

-K <name>

connect using a saved connection

-e

disconnect and clear connection data

mongodb : <json-command>

execute a native database command document

mongodb dump [file.json] [-f]

create an Extended JSON logical dump

mongodb load <file.json>

restore a lil MongoDB dump

Inspection

-l lists databases, -t lists collections, -s lists indexes, -n previews documents and -f matches one field/value pair. -o exports a collection as JSON.

Editing

-a inserts a JSON document. -w applies $set to documents matching one field/value pair. -d deletes documents matching one field/value pair. Complex operations remain available through native command documents after :.

Dump and restore

dump stores collections as canonical Extended JSON strings when the driver supports them, preserving BSON types better than ordinary JSON. load restores lil MongoDB dumps. Use mongodump for server-wide backups that require every MongoDB feature.

Connection

-c accepts either a host or a full mongodb:// / mongodb+srv:// URI. If a separate user is supplied, the password is requested outside command history unless -n is used.

Safety

Commands run with the privileges of the supplied MongoDB credentials.

When a full MongoDB URI includes a database path and no separate database argument is supplied, that path becomes the selected database. lil dumps are data-only and do not recreate collection options or indexes; export and dump refuse collections above 100000 documents instead of writing partial data.

Saved connections

Without -m, connection data remains scoped to the current PHP session. -m [name] explicitly stores the current profile in the protected .lil.key file (0600), -K <name> reconnects from it, -k lists or inspects profiles without exposing a stored password, and -M <name> removes one. kill removes .lil.key together with the other core state. Treat the file as sensitive because an opted-in profile can contain database credentials.

Interactive sandbox preview

Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.

Inspect a MongoDB collection

Install and manage

Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.

Base and Minimum are two packages of the same current module release, not separate command versions.

Base package

Install the complete package with local command reference and every published mode.

install mongodb
Minimum package

Install the reduced package. Local reference is omitted; help <cmd> -i opens the current server reference.

install mongodb -m
Exact public version

Install exactly this published version.

install mongodb -v 1.1.3
Check or update

Ask upgrade to check compatibility and replace the installed block only when needed.

upgrade mongodb
Remove module

Remove the extension block while leaving the core and unrelated modules intact.

install mongodb -u

Examples

Examples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.

Inspect a MongoDB collection
mongodb -use shop | mongodb -t | mongodb -n products 5
Database  shop

products
orders

{"sku":"SHOE-1","name":"City shoe","category":"shoes","price":79.9}
{"sku":"BAG-1","name":"Canvas bag","category":"bags","price":44.5}
Mongodb · localhost
mongodb -c localhost app shop
Status    connected
Server    localhost
Database  shop
Version   8.x
Mongodb · -c
mongodb -c mongodb://localhost/shop -n
Status    connected
Server    localhost
Database  shop
Version   8.x
Mongodb · -l
mongodb -l
admin
config
shop
Mongodb · products
mongodb -s products
_id_  {"_id":1}
sku_1  {"sku":1}
Mongodb · products
mongodb -f products sku SHOE-1 20
{"sku":"SHOE-1","name":"City shoe","price":79.9}
Mongodb · products
mongodb -o products products.json
Saved  products.json
Mongodb · products
mongodb -a products : {"sku":"BAG-1","name":"Travel bag","price":49.90}
Inserted  1
ID        generated
Mongodb · products
mongodb -w products sku BAG-1 : {"price":44.90}
Matched  1
Updated  1
Mongodb · products
mongodb -d products sku BAG-1
Deleted  1
Mongodb · 11
mongodb : {"count":"products"}
{"n":4,"ok":1}
Mongodb · dump
mongodb dump shop.json
Saved  shop.json
Mongodb · load
mongodb load \sandbox\db\mongodb.json
Restored  2
Mongodb · -e
mongodb -e
+
Handle a missing collection
mongodb -s missing_collection
Collection not found: missing_collection

File used in this example: sandbox/db/mongodb.json

The example uses a file or directory from the protected /sandbox/ documentation workspace.

{
  "format": "lil-mongodb-json",
  "version": 1,
  "database": "shop",
  "created": "2026-08-09T00:00:00+00:00",
  "collections": {
    "products": [
      "{\"sku\":\"SHOE-1\",\"name\":\"City shoe\",\"category\":\"shoes\",\"price\":79.9,\"active\":true}",
      "{\"sku\":\"BAG-1\",\"name\":\"Canvas bag\",\"category\":\"bags\",\"price\":44.5,\"active\":true}"
    ]
  }
}

Related documentation

Current public release

v1.1.32026-08-14

Saved connections

Adds explicit -m/-M/-k/-K profiles in .lil.key; listings never reveal a stored password.