Created
April 28, 2017 14:19
Mongoose Config
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
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