O'Reilly logo

Mastering JavaScript Single Page Application Development by John Moore, Philip Klauzinski

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

Incorporating MongoDB into the SPA

All this command-line stuff is great, but we need to start incorporating our MongoDB database into our SPA. In a future chapter, we will introduce the mongoose plugin for node, which will allow us to do data modeling, and which will perform a lot of heavy lifting for us.

For now, we're going to add a connection to MongoDB into our SPA in a simple way, which will highlight how to incorporate our database and display some dynamic data.

Adding the NPM modules

For this chapter, we need two modules to connect and easily access our MongoDB database inside our Express application. Those modules are mongodb and monk.

In your terminal, navigate to your giftapp directory and type the following (remember to lead with sudo

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