π Using the Library Database
Running the lab in Instruqt / GitHub Codespacesβ
If you haven't already, review the database that is already in your local custer.
- Visual Studio Code
- MongoDB Shell
Select the correct database.

In Instruqt you can connect to the local cluster using the built-in terminal. Click on the Terminal tab, then start mongosh by typing:
mongosh
Then you can select the library database by typing:
use library
You can show all collections with:
show collections

π¦ΈββοΈ π» How would you switch to a database called orders?
Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab.
Answer
use orders
Even if this database does not yet exist, MongoDB can change to it. If we create a collection, users, etc., then this DB will be created.
Remember to get back to the library database by using:
use library
π¦ΈββοΈ π» Showing all databases
Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab.
You can also list other databases in your MongoDB instance with:
show databases
π¦ΈββοΈ Using MongoDB Atlas or your local MongoDB instanceβ
If you're using Instruqt, you can skip to the next section.
π» We'll use the library database for all of the hands-on exercises in this lab. If you're using your own MongoDB Atlas cluster, or a local MongoDB installation, import the library data into your database cluster.
- Atlas UI
- MongoDB Shell
Select the correct database in the aggregation pipeline builder.

To do that, in a MongoDB shell, type:
use library
You can show all collections with:
show collections
π¦ΈββοΈ π» How would you switch to a database called orders?
Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab.
Answer
use orders
Even if this database does not yet exist, MongoDB can change to it. If we create a collection, users, etc., then this DB will be created.
Remember to get back to the library database by using:
use library
π¦ΈββοΈ π» Showing all databases
Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab.
You can also list other databases in your MongoDB instance with:
show databases