// Node and npm are required for this gist
// Install mongoose
npm install mongoose

// On https://mlab.com/create click on Free Sandbox and give your DB a name
// You are then given a database on the next screen
// Give your database a new username and password

// The mongo shell and MongoDB URI should now be visible 

// In your project folder, make a config folder and a config.json file with your uname and password
{
  "uname": "[[insert uname]]",
  "pword":   "[[insert pword]]"
}

// Make a new file in the config folder called index.js and require config
var configValues = require('./config'); 

// Export an object and connect to mongo
module.exports = {
  getDbConnectionString: function () {
    return 'mongodb://' + configValues.uname ':' + configValues.pwd + '@ds019058.mlab.com/[[insert database name]]'
  }
}

// Create a new folder called models and a new file called mongoModel.js
// Require mongoose
var mongoose = require('mongoose');

var Schema = mongoose.Schema;

var mongoSchema = new Schema({
  item: String,
  item2: Boolean
});

var Mongo = mongoose.model('Mongo', mongoSchema);

// Export the model
module.exports = Mongo;

// In app.js require mongoose, config folder and connect to mongoose
mongoose.connect(config.getDbConnectionString());