There are a few options for using MongoDB in your project. You could install MongoDB locally, or we can use an online database and connect to it using the URI string.

We'll be connecting to a database we create on mLab. Once you create an account, you can setup a free database and use the connection string that looks like this: mongodb://<user>:<pass>@localhost/<dbname>.

Install mongoose with:

npm install --save mongoose

Then use it in your project by bringing it in:

var mongoose = require('mongoose');

And configuring it:

mongoose.connect('mongodb://<user>:<pass>@localhost/<dbname>');

Chris Sevilleja

162 posts

Co-founder of Scotch.io. Slapping the keyboard until something good happens.