Last active
August 29, 2015 14:16
-
-
Save kacole2/f7dd21b778df1519e5b1 to your computer and use it in GitHub Desktop.
mongodb and cloud foundry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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