Command console
- MongoDB
The command console runs MongoDB command documents, such as { find: … }, { aggregate: … } or
{ collStats: … }, against the database you pick. The documents a command returns show in the same
tree, table and JSON views as the collection view, and the server’s messages in a separate tab.
Every run goes into the query history.
Each run takes one command document. To write a query as db.products.find(…), use the find()
text of the collection view instead.
Run a command
Section titled “Run a command”-
Open a console: choose Open console from a database’s or collection’s menu in the explorer, or New query tab from the connection’s menu.
-
Pick the Database the command runs against.
-
Type a command document in Extended JSON or mongosh syntax:
{ find: "products", filter: { price: { $gt: 500 } }, sort: { price: -1 }, limit: 20 } -
Choose Run, or press Ctrl + Enter (Cmd + Enter on macOS).
Commands that return a cursor, such as find, aggregate or listCollections, stream a page at
a time and fetch more as you scroll. Cancel stops a running command.
Results and messages
Section titled “Results and messages”- Results shows the documents in the Tree, Table or JSON view. The footer shows the connection, the server version and how many documents were returned.
- Messages lists the run’s messages with their time; a count of errors appears on the tab.
Console results are read-only. To edit documents, use the collection view.
Write rules
Section titled “Write rules”| Connection | What happens |
|---|---|
| Read-only | Commands that write are refused. |
| Production, or confirm writes | Every command that writes asks first. |
| Any | Destructive commands, such as { drop: "customers" }, ask first. |
Declining the confirmation runs nothing.
From the command line
Section titled “From the command line”querybara query runs the same command documents against a saved profile or a MongoDB URI. An array
of commands runs in order. The documents print as relaxed Extended JSON; --format json prints
canonical Extended JSON as one array and --format jsonl one document per line.
querybara query "mongodb://[email protected]:27017/catalog" -e '{ find: "products", filter: { price: { $gt: 500 } } }'The same write rules apply: --read-only refuses commands that write, and destructive commands ask
in a terminal or need --yes.
Related
Section titled “Related”Documents Querybara 0.1.1 · built frombc9f5aa