Exercise 3: Running queries in IntelliShell and viewing the results

In this exercise, you will execute the queries you created in the second exercise.

As part of this process, you will use several IntelliShell features to run the queries and view the results in different formats.

To run the queries and view the results

1. On the IntelliShell tab, position your cursor after the third command in the editor – the last command you created in the previous exercise – db.bios.find({contribs:"ALGOL"}).pretty(); – and click the Execute statement at cursor button (execute at cursor) on the toolbar.

The result tab should show two documents, both containing ALGOL as a contribs value.

The following figure shows the first document included in the results.

Notice that the tab is named Shell Output. This is the name assigned to the tab when the Raw shell mode button is selected.

When this mode is used, all results appear in the Shell Output tab, regardless of the type of query.

2. On the IntelliShell toolbar, de-select the Raw shell mode button (raw shell mode).

3. Select (highlight) the second and third commands, as shown in the following figure.

select highlight

4. Click the Execute selection button (execute at cursor) on the toolbar.

IntelliShell will run the two selected commands. The bottom window should now contain two result tabs: Text and Find.

  • The Text tab displays the message returned by running the first selected command (the use statement)
  • The Find tab displays the documents returned by running the second selected command (the find query).

The following figure shows the Find tab, with the results displayed in Tree View and the first document expanded.

Result tab

IntelliShell names the result tabs based on the type of query. Because the use statement returns only a message, the return tab for this command is named Text.

For queries that return document data, IntelliShell often names the tab after the method used within this query.

For example, the find method is used in the second command, so the result tab is named Find. However, if the aggregate method had been used, the result tab would have been named Aggregate.

The Find tab (and other tabs of this kind) include many of the same features as a collection tab. For example, you can add, edit, or delete documents. You can also view the results in Tree View, Table View, or JSON View, as well as set several display properties.

Feel free to experiment with the different features to become better acquainted with ways of displaying results.

5. When you are finished experimenting with the different display features, close IntelliShell.

If prompted to save changes, click No.

6. Close the bios collection tab.

7. In the Connection Tree, right-click the BioData database node and click Drop Database.

8. In the Drop Database dialog box, click Drop Database.

9. Close Studio 3T.

You’ve finished the exercise! Click on Test your skills to review what you’ve learned.

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