Skip to content
Studio 3T - The professional GUI, IDE and client for MongoDB
  • Tools
    • Aggregation Editor
    • IntelliShell
    • Visual Query Builder
    • Export Wizard
    • Import Wizard
    • Query Code
    • SQL Query
    • Connect
    • Schema Explorer
    • Compare
    • SQL ⇔ MongoDB Migration
    • Data Masking
    • Task Scheduler
    • Reschema
    • More Tools and Features
  • Solutions
  • Resources
    • Knowledge Base
    • MongoDB Tutorials & Courses
    • Tool/Feature Documentation
    • Blog
    • Community
    • Testimonials
    • Whitepapers
    • Reports
  • Contact us
    • Contact
    • Sales Support
    • Feedback and Support
    • Careers
    • About Us
  • Store
    • Buy Now
    • Preferred Resellers
    • Team Pricing
  • Download
  • My 3T
search

Academy 3T

  • Explore our courses
    • MongoDB 101: Getting Started
    • MongoDB 201: Querying MongoDB Data
    • MongoDB 301: Aggregation
  • Get certified

Lesson 7: Introducing IntelliShell

MongoDB 101: Getting Started Running MongoDB Queries on the mongo Shell Lesson 7: Introducing IntelliShell

IntelliShell offers the simplicity of the mongo shell, but adds an assortment of features to make it easier to query a database and view the results.

You can launch IntelliShell from the Studio 3T menu or through the Connection Tree. For example, you can launch IntelliShell from a database or collection node.

IntelliShell opens as a separate tab, which is divided into two sections.

The top section provides tools and a window (the Editor) for building and running commands against a MongoDB database.

The bottom section is a separate window that displays one or more result tabs. The number and name of the tabs will depend on how you configure the IntelliShell options and the type of queries you run.

The following figure shows the IntelliShell tab, with the main components outlined.

IntelliShell and its main components

The components on the IntelliShell tab can be broken down as follows:

  • Current database: Shows the currently active database, which you can change by running a use statement. When you change the database context, IntelliShell automatically updates the database name on the top label.
  • Query History: Launches the IntelliShell Script Manager dialog box, where you can view the past queries you’ve executed, copy them into the Editor, or clear the query history. You can also view your bookmarks by clicking on the Bookmarks tab.
  • Bookmark Manager: Clicking on the star icon prompts you to save a query or script as a bookmark. Clicking on the down arrow leads you to the Bookmark Manager where you can view previous bookmarks.
  • Show editor and result tabs horizontally or vertically: Allows you to choose between a horizontal or vertical orientation of IntelliShell’s tabs.
  • IntelliShell toolbar: A set of tools for running queries and viewing results. The individual tools are described in the table below.
  • IntelliShell editor: The actual command-line interface where you type commands that can be executed against the current database. You can run individual commands or multiple commands together.
  • Result tab: A tab that displays the results from executing one or more queries. Multiple result tabs can be open at the same time, with different names for the tabs. That tab name depends on the IntelliShell settings and the type of queries. For example, the above figure shows the Raw Shell Output tab, which is used for all queries when Query Assist is disabled on the toolbar.

The IntelliShell toolbar includes a set of tools for running queries and displaying their results. The following table describes the tools in the order they appear on the toolbar (from left to right).

OptionIconDescription
Add new scriptNew script iconAdds new script which also clears the editor. If there are unsaved changes to a current script, Studio 3T will prompt you to save them.
Open a script
Folder icon
Opens a script file in the Editor, where you can then edit and run the commands, either individually or grouped together.
Save the current script
save icon
Saves the current set of commands to a script file.
Run entire script
Execute entire script
Runs all commands currently typed into the Editor.
Run statement at cursor
Script at cursor
Runs the command where the cursor is positioned. The command can span multiple lines.
Run selection
Execute selection
Runs all selected commands. The option is grayed out if no text is selected.
Enable auto-completionAuto-completion iconEnables or disables auto-suggestion of hints as you type.
Enable Query AssistEnable Query Assist iconRuns the query on Studio 3T instead of the mongo shell. This is enabled by default.
Format codeFormat code iconFormats the code.
Shell Methods ReferenceOpens a webpage on the MongoDB website, where you can access information about the various methods available to the mongo shell.
Show Visual Query Builder Launches the Visual Query Builder.

What is Query Assist?

Query Assist is enabled by default for standalone, top-level find and aggregation queries. This means they will be run through Studio 3T instead of the mongo shell.

Query Assist adds functionalities that are not available for shell-run queries, like the ability to:

– Run find and aggregation queries that open their own powerful result tabs. Find queries run using Query Assist allow in-place editing.
– Edit results within the tabs, as you normally would in other parts of Studio 3T through the three standard views: Table, Tree, and JSON.
– Use Query Code to convert your MongoDB query to JavaScript (Node.js), Java (2.x and 3.x driver API), Python, C#, PHP, and Ruby.
– Use Visual Explain to help optimize performance by seeing how MongoDB executed your query.

Query Assist only assists find and aggregation queries – all other scripts and commands will always be run in the shell. Their results are viewable in the the Raw Shell Output tab.

From the IntelliShell Editor, you can also load and run script files with a single command. In this way, you don’t have to retype the same commands each time you want to execute them. This is especially useful for testing applications or features that require you to set up a clean environment with each test cycle.

For example, the following commands are part of a simple script file that defines a variable, creates a database, and adds a collection to the database:

obj_id = ObjectId();
 db = new Mongo().getDB("Authors");
 db.getCollection("19th_century").insertMany([
 {
   _id: obj_id,
   pen_name: { first: "Mary", last: "Shelley" },
 },
 {
   name: { first: "Mary", middle: "Wollstonecraft", last: "Shelley" },
   pen_id: obj_id,
   tags: ["novelist", "dramatist", "biographer", "travel writer"],
   dates: 
     {
       born: ISODate("1797-08-30"),
       married: ISODate("1814-07-28"),
       died: ISODate("1851-02-01")
     }
 }]);

When you access a database directly through the mongo shell, you can achieve the same results with the use command, but this approach does not work when loading and running a script file. In this case, you must work with the database object, which you access through the db variable.

Be careful when creating a script file and ensure that all elements will work as expected.

In most cases, running commands in a script file works the same as running them directly within the Editor, with a few notable exceptions, such as accessing the database object.

Previous Lesson
Back to Lesson
Next Topic
  • Course Home Expand All
    Introduction to MongoDB and Studio 3T
    1 Quiz
    Test your skills: Introduction to MongoDB and Studio 3T
    Introduction to MongoDB Atlas
    1 Topic
    Lesson 2, Exercise: Setting up MongoDB Atlas
    Connecting to MongoDB
    1 Topic | 1 Quiz
    Lesson 3, Exercise: Connecting to MongoDB via Studio 3T
    Test your skills: Connecting to MongoDB
    The MongoDB Basics: Databases, Collections & Documents
    7 Topics | 2 Quizzes
    Lesson 4: Understanding MongoDB Documents: Fields & Data Types
    Test your skills: Understanding MongoDB Documents
    Lesson 4: Comparing MongoDB vs SQL Concepts
    Lesson 4, Exercise 1: Creating a collection from a .json file
    Test your skills: Creating a Collection
    Lesson 4, Exercise 2: Reviewing the collection in different views
    Lesson 4, Exercise 3: Using Visual Query Builder to query data
    Lesson 4, Exercise 4: Updating data directly within the collection
    Post-Basics Course Feedback
    Using SQL in MongoDB Aggregation
    3 Topics | 1 Quiz
    Lesson 5, Exercise 1: Running a SQL aggregate query in MongoDB
    Test your skills: Using SQL in MongoDB Aggregation
    Lesson 5, Exercise 2: Exporting a SQL query to the Aggregation Editor
    Lesson 5, Exercise 3: Editing a query in the Aggregation Editor
    Importing and Exporting MongoDB Data
    3 Topics | 1 Quiz
    Lesson 6, Exercise 1: Importing document data from a .csv file
    Lesson 6, Exercise 2: Exporting document data to a .json file
    Lesson 6, Exercise 3: Exporting document data to a new collection
    Test your skills: Importing and Exporting MongoDB Data
    Running MongoDB Queries on the mongo Shell
    4 Topics | 1 Quiz
    Lesson 7: Introducing IntelliShell
    Lesson 7, Exercise 1: Using IntelliShell to load and run a script file
    Lesson 7, Exercise 2: Using IntelliShell’s auto-completion features to write queries
    Lesson 7, Exercise 3: Running queries in IntelliShell and viewing the results
    Test your skills: Running MongoDB Queries on the mongo Shell
    Course Extras
    Return to MongoDB 101: Getting Started
  • Studio 3T

    MongoDB Enterprise Certified Technology PartnerSince 2014, 3T has been helping thousands of MongoDB developers and administrators with their everyday jobs by providing the finest MongoDB tools on the market. We guarantee the best compatibility with current and legacy releases of MongoDB, continue to deliver new features with every new software release, and provide high quality support.

    Find us on FacebookFind us on TwitterFind us on YouTubeFind us on LinkedIn

    Education

    • Free MongoDB Tutorials
    • Connect to MongoDB
    • Connect to MongoDB Atlas
    • Import Data to MongoDB
    • Export MongoDB Data
    • Build Aggregation Queries
    • Query MongoDB with SQL
    • Migrate from SQL to MongoDB

    Resources

    • Feedback and Support
    • Sales Support
    • Knowledge Base
    • FAQ
    • Reports
    • White Papers
    • Testimonials
    • Discounts

    Company

    • About Us
    • Blog
    • Careers
    • Legal
    • Press
    • Privacy Policy
    • EULA

    © 2023 3T Software Labs Ltd. All rights reserved.

    • Privacy Policy
    • Cookie settings
    • Impressum

    We value your privacy

    With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data.

    By clicking “Accept all”, you consent to the storage of cookies and the processing of personal data for these purposes, including any transfers to third countries. By clicking on “Decline all”, you do not give your consent and we will only store cookies that are necessary for our website. You can customize the cookies we store on your device or change your selection at any time - thus also revoking your consent with effect for the future - under “Manage Cookies”, or “Cookie Settings” at the bottom of the page. You can find further information in our Privacy Policy.
    Accept all
    Decline all
    Manage cookies
    ✕

    Privacy Preference Center

    With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data. Please choose for which purposes you wish to give us your consent and store your preferences by clicking on “Accept selected”. You can find further information in our Privacy Policy.

    Accept all cookies

    Manage consent preferences

    Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.

    Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.

    Google Analytics

    Google Ads

    Bing Ads

    Facebook

    LinkedIn

    Quora

    Hotjar

    Reddit

    Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.

    HubSpot

    Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.

    Accept selected