O'Reilly logo

Continuous Integration, Delivery, and Deployment by Sander Rossel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required