Yjohn / api-workshop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

README

how to populate the database

  1. open the terminal and run: sudo mongod.
  2. open another terminal and run: mongo.
  3. in the previous terminal run: use apiworkshop.
  4. 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
    }
]
  1. then run: db.products.insertMany(paste the previous array here).
  2. if you want to see how many documents you insert:- db.products.count().
  3. if you want to see what you inserted run:- db.products.find().pretty().

Database name is

apiworkshop

collection name is

products

About


Languages

Language:JavaScript 52.5%Language:CSS 27.6%Language:HTML 19.9%