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
Get Mastering JavaScript Single Page Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.