MongoDB query tool CLI
A MongoDB query tool CLI is a terminal program that reads a MongoDB database. MongoDB is a document database. SQL (Structured Query Language) is the language a relational database runs, and this path rejects it. The command-line interface (CLI) is the datatug program in a terminal. TugQL is DataTug's query language for one collection, filters and columns. BSON (Binary JSON) is MongoDB's binary document format, and JSON (JavaScript Object Notation) is a text format the command can print. A read-role identity is a database login allowed to read. Query run is the datatug command that reads rows. A Web UI (user interface) is the browser and the hosted app, and this page does not claim that path. To query MongoDB from the CLI, DataTug runs TugQL through query run. Redis is an in-memory data store with its own page. MongoDB direct CLI queries have been available since DataTug CLI 0.125.1.
The command the guide shows
The source guide is docs/databases/mongodb.md at the CLI revision the supported databases catalogue cites. DataTug CLI is open source under the Apache License 2.0. The command it shows is:
export SHOP_MONGO_URL='mongodb://reader:password@localhost:27017/shop?authSource=shop'
datatug query run --db env:SHOP_MONGO_URL --from products --no-policies --format jsonThe password in that example is the guide's placeholder. The address lives in an environment variable, a name the operating system holds outside the project files, and --db env:SHOP_MONGO_URL reads it. The address must select the database. mongodb:// and mongodb+srv:// both work. Use a database read-role identity. --from products names one root collection. --format json prints JSON.
The guide says --no-policies explicitly selects unrestricted reads for this local command. It is not a switch that removes write permission from the database login. Use a read-role identity when you only want to query.
What the query can say
The catalogue and the guide agree on the shape. One root collection. Scalar filters: the guide names top-level scalar equality and range comparisons, and AND and OR. Projection, which chooses fields. Ordering. Limits up to 1000. The guide says an omitted limit returns at most 1000 documents. Offsets up to 100000. A 16 MiB (mebibyte) BSON budget. MongoDB's own null, missing-field and comparison rules apply. An expression the path does not support fails explicitly.
A TugQL file can filter, project and order that collection. The guide shows this file, then the command under it. minPrice is a named value passed with --var, not text pasted into the filter.
from: {name: products}
columns:
- field: name
- field: price
where:
op: '>='
left: {field: price}
right: {param: minPrice}
orderBy:
- field: price
desc: true
limit: 20datatug query run --db env:SHOP_MONGO_URL -f products.tugql.yaml --var minPrice=10 --no-policies --format json| Question | What the CLI does |
|---|---|
| Address | mongodb:// or mongodb+srv://, and the address selects the database. The login is a read-role identity. |
| Query | TugQL via query run, since CLI 0.125.1. SQL text is rejected. The guide says --sql is for SQL sources. |
| Shape | One root collection, scalar filters, projection and ordering. |
| Bounds | Limits up to 1000, offsets up to 100000, and a 16 MiB BSON budget. |
| Browser and hosted app | Not verified by this catalogue. |
Policies
Configured DataTug policies use the shared structured-query executor. That is the catalogue's statement, and the guide says the same thing in the other direction: --no-policies is the explicit opt-out for a trusted local command. The guide says never to grant unrestricted source access to an untrusted principal. This page does not add a flag the guide does not show.
Browser and hosted use
Browser and hosted availability are unverified. The catalogue's Web UI cell for MongoDB reads "Not verified by this catalogue". This page does not claim the browser or the hosted app can query MongoDB. A local CLI check does not establish that path.
Redis, Firestore, and the catalogue
Redis query tool is the other direct CLI path from the same release. It reads keys with native commands and does not run TugQL. Query Firestore with SQL is the document-database page that also rejects SQL. The SQL CLI tool page is the terminal program these commands belong to. Install it from the installer.
The current reviewed catalogue release is DataTug CLI 0.136.1. MongoDB direct CLI queries have been available since DataTug CLI 0.125.1. The supported databases catalogue is the operation-by-operation list, and the MongoDB row stays at #mongodb.
