Skip to content

Instantly share code, notes, and snippets.

@kacole2
Last active August 29, 2015 14:16
Show Gist options
  • Save kacole2/f7dd21b778df1519e5b1 to your computer and use it in GitHub Desktop.
Save kacole2/f7dd21b778df1519e5b1 to your computer and use it in GitHub Desktop.
mongodb and cloud foundry
var mongoose = require('mongoose'),
cfenv = require("cfenv");
var appEnv = cfenv.getAppEnv()
var mongoLabUrl = appEnv.getServiceURL('my-mongo-database');
if (mongoLabUrl == null) {
//local or prod development
mongoose.connect('mongodb://localhost/my-mongo-database');
} else {
//cloud foundry
mongoose.connect(mongoLabUrl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment