- open the terminal and run:
sudo mongod
. - open another terminal and run:
mongo
. - in the previous terminal run:
use apiworkshop
. - copy this array to use it into the insertMany function in the next step.
[
{
"urlPath": "lorem",
"title": "Lorem",
"price": 21,
"rating": "4.5/5",
"commentCount": 3
},
{
"urlPath": "ipsum",
"title": "Ipsum",
"price": 15,
"rating": "4.75/5",
"commentCount": 1,
"isTopRated": true
},
{
"urlPath": "dolor",
"title": "Dolor",
"price": 32
},
{
"urlPath": "sit",
"title": "Sit",
"price": 42
},
{
"urlPath": "amet",
"title": "Amet",
"price": 12
}
]
- then run: db.products.insertMany(paste the previous array here).
- if you want to see how many documents you insert:- db.products.count().
- if you want to see what you inserted run:- db.products.find().pretty().
apiworkshop
products