Created
April 28, 2017 14:19
-
-
Save blackwright/5aa67e036b45f77a8f15f2a43d00ba01 to your computer and use it in GitHub Desktop.
Mongoose Config
This file contains hidden or 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
const mongoose = require("mongoose"); | |
const env = process.env.NODE_ENV || "development"; | |
const config = require("./config/mongo")[env]; | |
module.exports = () => { | |
const envUrl = process.env[config.use_env_variable]; | |
const localUrl = `mongodb://${config.host}/${config.database}`; | |
const mongoUrl = envUrl ? envUrl : localUrl; | |
return mongoose.connect(mongoUrl); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment