IntelliShell

IntelliShell is the built-in mongo shell with smart autocompletion of JavaScript standard library functions, shell-specific types and methods, operators, collection names, field names, shell helper commands, and more.

Open IntelliShell – Ctrl + L (⌘+ L)
Trigger autocompletion – Ctrl + Space (^ + Space)
Find – Ctrl + F (⌘+ F)
Replace – Ctrl + H (Shift + ⌘ + F)
Comment with line comment – Ctrl + / (⌘+ /)
Open script – Ctrl + O (⌘+ O)
Save script – Ctrl + S (⌘+ S)
Save script as – Shift + Ctrl + S (Shift + ⌘+ S)
Execute entire script – F5
Execute statement at cursor – F6
Execute selection – F9

Prerequisites

IntelliShell requires the mongo shell executable, one of the mongo client tools bundled when downloading MongoDB.

Windows and Mac

No additional configuration is needed for Windows and Mac installations. The mongo shell executable is bundled with Studio 3T on these systems.

Linux

Linux requires the manual installation of the mongo shell executable.

To install the mongo client tools, download the latest MongoDB version here.

Once the mongo client tools are installed:

  1. Go to Studio 3T > Preferences
  2. Click on the IntelliShell tab
  3. Insert the path of where the mongo shell executable is located.
    On Linux, this will be a binary file called mongo located in the ‘bin’ directory where the distribution was unpacked.
  4. Click OK

Basics

There are three ways to open IntelliShell:

Button

Click on the IntelliShell button in the global toolbar

Right-click

Right-click on a target collection and choose Open IntelliShell

Hotkey

Press Ctrl + L (⌘+ L)

IntelliShell has two main sections: the Editor where queries are written in a standard command line interface, and the Result Tab where results can be viewed and edited.

Need to download Studio 3T? Get the latest version.

Write a query

Users with the knowledge of the MongoDB query language can write queries directly in the Editor area.

Write a query using the editor in IntelliShell.

The full list of MongoDB shell operators can be found here, which is also directly accessible within Studio 3T through the Shell Methods Reference link in the toolbar.

Autocomplete a query

IntelliShell detects and autosuggests JavaScript standard library functions, shell-specific types and methods, operators, collection names, field names and shell helper commands as they are typed:

Autocompletion should be automatic, but it can also be triggered manually:

Right-click

Right-click anywhere in the Editor and choose Open Autocompletion

Hotkey

Press Ctrl + Space (^ + Space)

Still learning the MongoDB query language? Build queries via drag-and-drop instead with Visual Query Builder.

Execute a query

Queries can be executed entirely, at cursor, or as selected.

To execute an entire script:

Button

Click on the Run (play) button

Right-click

Right-click anywhere in the Editor and choose Execute Entire Script

Hotkey

Press F5

To execute a script at cursor, place the cursor at the target query and:

Button

Click on the second Run (play) button

Right-click

Right-click anywhere in the Editor and choose Execute Statement at Cursor

Hotkey

Press F6

To execute a selection, highlight the part of the query to be executed and:

Button

Click on the third Run (play) button

Right-click

Right-click anywhere in the Editor and choose Execute Selection

Hotkey

Press F9

Check query results

Results can be viewed in the Result Tab in either raw shell mode or the standard three views (Table, Tree, and JSON).

Enable raw shell mode

Raw shell mode displays query results in the usual mongo shell format.

To enable raw shell mode, click on the shell icon in the toolbar:

View multiple tabs

Multiple result tabs can only be viewed when raw shell mode is disabled. 

The Result Tab can display either a single tab, meaning results from previous queries are replaced by new ones, or multiple tabs, which is similar to how a browser works.

To view multiple tabs, click on the Retain button in the toolbar. Unclick it to revert to a single tab view.

 

Clear all result tabs

To close all result tabs:

Button

Click on the Clear button in the toolbar

Right-click

Right-click anywhere in the Editor and choose Clear Result Tabs

Insert and remove comments

It is also possible to comment and uncomment with a line comment.

Place the cursor on the line to be made into a comment and:

Right-click

Right-click anywhere in the Editor and choose Comment with Line Comment. Repeat to remove the comment. 

Hotkey

Press Ctrl + / (⌘+ /). Repeat to remove the comment.

Open and save queries

To save your MongoDB query as a JavaScript file:

Button

Click on the Save icon. Alternatively, click on the arrow to find the Save As function.

Right-click

Right-click anywhere in the Editor and choose Save Script (As)

Hotkey

Save Script – Ctrl + S (⌘+ S)
Save Script As – Shift + Ctrl + S (Shift + ⌘+ S) 

To open saved queries:

Button

Click on the Open icon

Right-click

Right-click anywhere in the Editor and choose Open Script

Hotkey

Press Ctrl + O (⌘+ O)

IntelliShell got even better and faster with Studio 3T 2018.4, which now supports autocompletion on JavaScript standard library functions, shell methods, more robust autosuggestion of field names and shell helper commands. Find the release notes here

Use IntelliShell and Visual Query Builder side by side

With Studio 3T 2018.5, you can use Visual Query Builder – our drag-and-drop MongoDB query builder – alongside our smart mongo shell.

Simply click on the Visual Query Builder button on the toolbar:

IntelliShell and Visual Query Builder in one view
This way, you can skip the command line writing and build queries visually, which could come in handy especially as your MongoDB queries get more complex.


Want to extend your use of the mongo shell? Read on:

Updated on December 12, 2018

Was this article helpful?

Related Articles