Running MongoDB Queries on the mongo Shell

Section
Materials

IntelliShell is a command-line tool built into Studio 3T that allows writing commands directly against a MongoDB database. It offers the simplicity of the mongo shell, which is what the tool is based on, while adding a number of important features that make it easier to query a database. For example, you can run commands individually, run multiple commands together, or run all commands at once.

IntelliShell also simplifies viewing results, as it lets you control how to display them – through Table, Tree, and JSON View. You can also work with the results like you can on a collection tab.

Although you were introduced to Studio 3T’s built-in mongo shell in previous lessons, your interactions with the tool were limited to simple query executions. In this section, you’ll dig into IntelliShell deeper to get a better sense of how it works and the features it supports.

To this end, you’ll load and run a script file that creates a database and adds a collection. You’ll then build and run a query that retrieves data from the collection, using the various IntelliShell features.

By the end of this section, you will learn how to:

  • Use the mongo shell/IntelliShell to load and run a script file
  • Use IntelliShell’s auto-complete features to write a query
  • Run a query in the mongo shell/IntelliShell and view the results

What you will need:

  • Access to a running instance of MongoDB
  • Ability to download a script file and save it to your local system

Terms you might not know:

command-line tool: a command-line interface or command language interpreter (CLI), also known as command-line user interface, console user interface, and character user interface (CUI), is a means of interacting with a computer program where the user (or client) issues commands to the program in the form of successive lines of text (command lines) (source)

Additional resources:

Log in

Log in to your Studio 3T Academy account

Forgot password?

Don't have an account yet? Sign up
Sign up

Start learning MongoDB today. All fields are mandatory.

By signing up for a course, you agree to the 3T Software Labs Privacy Policy.


Already have an account? Log in