Skip to content

IntelliShell

  • MongoDB

IntelliShell is a mongosh editor in a tab. Querybara embeds mongosh, so there is nothing to install: you write a script, run all of it, one statement or a selection, and each find() or aggregate() opens in a result tab of its own with the table, tree and JSON views. It is the query tab of a MongoDB connection, and writes follow the connection’s write rules.

  • Choose Open IntelliShell from a database’s, a collection’s or a Collections folder’s menu in the explorer. From a collection, the editor starts with that collection’s find({}).
  • Press Ctrl + L (Cmd + L on macOS), or choose IntelliShell in the toolbar. It opens on the connection, database and collection in view.
  • Choose New query tab in a MongoDB connection’s menu, or press Ctrl + T (Cmd + T on macOS) with a MongoDB tab in front.
  • In a collection tab, choose Open query in… › IntelliShell, or Open in IntelliShell in the Query Code section. The editor starts with the tab’s query.

The tab is named IntelliShell: and the connection’s name. Above the editor, the breadcrumb shows the connection and the Database the shell is in; pick another database from the list to switch, as use does. A read-only connection shows Read-only there.

  1. Type the script. Completion offers collections, methods, operators and the field names of the collection a query is about, sampled from its documents. Press Ctrl + Space to show it.
  2. Run it with a key or a toolbar button (see the table below).
  3. Read the output under the editor: the Raw shell output tab, and a result tab for each query.
use shop
const since = ISODate('2026-01-01T00:00:00Z');
db.orders.find({ createdAt: { $gte: since } }).sort({ total: -1 }).limit(20)
db.orders.aggregate([{ $group: { _id: '$status', orders: { $sum: 1 } } }])

This script opens two result tabs, Find Query (line 3) and Aggregate Query (line 4).

Runs Keys
The entire script (Run) F5
The statement at the cursor F6
The selection F9
The selection, or the entire script Shift + Enter
The selection, or the statement at the cursor Ctrl + Enter (Cmd + Enter on macOS)

The two buttons beside Run in the toolbar run the statement at the cursor and the selection.

The script runs one top-level statement at a time, and use and show lines run as commands. The line under the editor shows the cursor’s line and column and No errors, or the syntax error in the text as you type. A script with a syntax error runs nothing. A statement that fails stops the script there, and the editor marks where the error points.

Stop stops a running script at mongosh’s next checkpoint. A script that does not stop within 3 seconds, such as a while (true) {} loop, has its shell restarted in the same database: its variables and open results are gone, and the output says so.

Raw shell output collects what mongosh prints: each statement after a >, its output, and errors. Values print as mongosh prints them, such as the list of show dbs or dates as ISODate. Above it:

  • Restart shell starts a new shell in the same database. Variables and open results are gone.
  • Clear raw shell output clears it; typing cls in a script does too.
  • Pin new results keeps the result tabs of the next runs (see below).

With Query Assist ticked in the toolbar, as it is to start with, each cursor opens a result tab named after its kind and line: Find Query, Aggregate Query, Command or Change Stream. A result tab:

  • shows the documents with their exact BSON types: Int32, Int64, Double and Decimal128 stay apart;
  • loads 100 documents at a time; Fetch more loads the next ones;
  • switches between Table View, Tree View and JSON View in the View list, or with Ctrl + Alt + 1, 2 and 3 (Cmd + Option on macOS);
  • offers Open in collection tab for a find(), which opens the collection tab with the query filled in so you can page and edit, or Open in Aggregation Editor for an aggregate();
  • offers Query code…, which exports the query as a program (Export query as code);
  • shows how long the statement took.

Result tabs are read-only; right-click a document for Copy Document and Copy as Extended JSON. When the shell read a cursor itself (in a map(), for example), the tab says Types as the shell sees them.

A run replaces the result tabs of the run before, except pinned ones. Choose the pin on a tab to keep it, or tick Pin new results to keep every new one. Each tab has its own close button.

Without Query Assist, query results print in the raw output, and when there are more documents the output says to type it, which shows the next ones.

Change view puts the results beside the editor instead of under it. Drag the bar between them to resize.

The status bar shows the connection, the mongosh and MongoDB versions, how many statements the last run ran and how long it took, and whether the shell is connected.

IntelliShell applies the connection’s write rules to every write a script makes:

Connection What happens
Read-only Writes are refused.
Production, or confirm writes Every write asks first.
Any Destructive operations, such as db.customers.drop(), ask first.

The question shows the operation and the namespace it acts on:

  • Run runs it.
  • Run all writes runs it and every other write of this run without asking again.
  • Don’t run refuses it, and the script stops there as at any error.

Mongo() and connect() are refused, so a script stays on the connection it was opened on. When a script asks for a password, a dialog asks for it.

A script that is a single command document runs as a command:

{ find: "products", filter: { price: { $gt: 500 } }, sort: { price: -1 }, limit: 20 }

Commands that return a cursor, such as find, aggregate or listCollections, open a result tab and page like any other cursor. Commands that only run on admin go to admin. Tabs of the command console of earlier versions reopen as IntelliShell tabs with their text.

  • New clears the editor.
  • Load script opens a .js, .mongodb or .txt file.
  • Save script › Save writes the script back to its file; Save as… asks where (script.js to start with).
  • Script history lists the latest entries of the connection’s query history; choose one to put it in the editor. Every run goes to the query history.

The editor’s text is autosaved and comes back after a crash, as a query tab’s does.

querybara query runs command documents against a saved profile or a MongoDB URI; scripts run in the app only. 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.

Terminal window
querybara query "mongodb://[email protected]:27017/shop" -e '{ find: "products", filter: { price: { $gt: 500 } } }'
querybara query "mongodb://[email protected]:27017/shop" -f commands.json --format jsonl

The same write rules apply: --read-only refuses commands that write, and destructive commands ask in a terminal or need --yes.

Documents Querybara 0.1.19 · built from89dc752