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.
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
if you're on a Mac or Linux):
npm install mongodb --save ... npm install monk -save
The dependencies section of your package.json
file should now look something like this:
"dependencies": { "body-parser": "~1.13.2", "cookie-parser...