Moving our Products to MongoDB

We still have that weird repository.js file that has some hardcoded products in it. Having products like that in a JavaScript file is not going to work, so let's move them to the database as well. Again, we are going to insert them manually, but this time, we can create a little script that inserts all of the products at once. In Robomongo, right-click on the database and pick Open Shell.... This opens a new tab with a single line for you to type in. Do not worry, you can enter as many new lines as you want.

Your command will simply be some JavaScript and, since we already have all our products written down in JavaScript, this is basically a copy and paste action:

db.getCollection("product").insert([{ id: 1, ...

Get Continuous Integration, Delivery, and Deployment now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.