Skip to content

Instantly share code, notes, and snippets.

@kharmabum
Created August 4, 2013 18:52
Show Gist options
  • Save kharmabum/6151433 to your computer and use it in GitHub Desktop.
Save kharmabum/6151433 to your computer and use it in GitHub Desktop.
configure mongodb database w/ node
var config = {
"USER" : "",
"PASS" : "",
"HOST" : "ec2-xx-xx-xx-xx.ap-southeast-2.compute.amazonaws.com", "PORT" : "27017",
"DATABASE" : "my_example"
};
var dbPath = "mongodb://" + config.USER + ":" + config.PASS + "@" + config.HOST + ":" + config.PORT + "/" + config.DATABASE;
var mongoose = require('mongoose');
var db = mongoose.connect(dbPath);
mongoose.connection.once('open', function() {
// register mondels, etc
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment