Section 25 – Lesson 342 – Complete 2020 Web Development Bootcamp

Lesson 342 – MongoDB CRUD Operations in the Shell: Create

To start a mongo database, in the Hyper terminal type –


The next step is to click “Shell” in the Hyper terminal and then click “New Tab” to open another terminal.

In the new terminal you then type –


To get help while using the Mongo shell just type this in the terminal –


To see the databases you currently have, type this in the mongo shell –

show dbs

To create a new shop database in the mongo shell you type –

use shopDB

To find out which database you are currently in type –


To create a new collection in the database and insert a new item in that collection, you can use this code –

db.products.insertOne({_id: 1, name: "Pen", price: 1.20})

To see all the collections that currently exist, you can type –

show collections

The challenge in this lesson is to create a second product “Pencil” in the products collection.

To complete this challenge, you type this in the Mongo shell –

db.products.insertOne({_id: 2, name: "Pencil", price: 0.80})