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, Exercise 1: Using IntelliShell to load and run a script file

MongoDB 101: Getting Started Running MongoDB Queries on the mongo Shell Lesson 7, Exercise 1: Using IntelliShell to load and run a script file

In this exercise, you will load and run the bios.js file.

Download the bios.js file here.

The file contains a set of commands that create a database named BioData and add a collection to the database named bios. The collection includes 10 documents that contain biographical information about 10 individuals, one document per individual.

The document data comes from a sample collection available through the MongoDB Server manual. You can use this dataset to learn about MongoDB and test its features.

To load and run the script file

1. Launch Studio 3T and connect to MongoDB.

2. In the Connection Tree, right-click the connection (top-level node) and choose Add Database.

3. In the Add Database dialog box, type BioData in the Database Name text box, and then click OK.

add biodata

Studio 3T adds the BioData database node to the Connection Tree.

4. In the Connection Tree, right-click on the database (BioData) and click Open IntelliShell.

open intellishell

5. If you haven’t already done so, download the bios.js file and save it to a local folder on your system.

6. On the IntelliShell toolbar, click on the lightning bolt icon (Auto-completion icon) to trigger auto-completion. IntelliShell will then auto-suggest hints as you type.

Enable Query Assist is on by default. Click on the button to disable it. This ensures that, for this exercise, the results are displayed on a single result tab.

The IntelliShell toolbar should look like this:

7. In the IntelliShell editor, delete any existing commands and type the following command, replacing the <path> placeholder with the actual folder path:

load("<path>bios.js");

Backslashes can be interpreted in different ways, often indicated by an escape character.  When specifying the path, you might need to escape any backslashes by adding an additional backslash to each one.

For example, if you’re working in Windows and save the bios.js file to the folder C:\DataFiles\MongoDB, you would type the following command in the IntelliShell editor:

load("C:\\DataFiles\\MongoDB\\bios.js");

macOS, on the other hand, uses forward slashes. If saving to the same folder, you would type the following command:

load("/DataFiles/MongoDB/bios.js");

The load method loads and runs a script file, which in this case is bios.js.

8. Click the Run entire script button (Execute entire script). You should receive a message that says true.

intellishell authentication true

9. In the Connection Tree, right-click the connection (top-level node) and click Refresh All.

This creates the bios collection.

10. Expand the BioData database node, and then expand the Collections node if necessary.

Double-click the bios collection node to open the collection in its own tab.

11. Go to the bios collection tab and review the 10 documents, using Tree View, Table View, or JSON View.

Tree view

The documents include the following fields:

  • The _id field is a unique Int32 value that identifies the document.
  • The name field is an embedded document that provides the individual’s first and last name, along with other names, if applicable.
  • The birth field is a Date value that indicates when the individual was born.
  • The death field is a Date value that indicates when the individual died.
  • The contribs field is an array that lists the individual’s contributions to technology.
  • The awards field is as an array in which each element is an embedded document that includes specific award information.
  • The title field is a String value that lists the individual’s title. Not all documents contain every field; however, each document includes at least the _id, name, and contribs fields. Leave the bios collection tab open for now in case you want to reference the documents in later exercises to see how they’re constructed.
Previous Topic
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