Created
August 1, 2019 12:29
-
-
Save acomito/60adf8375a5de7596530c11268bbdcbf to your computer and use it in GitHub Desktop.
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
/// | |
import mongoose from 'mongoose'; | |
import dotenv from 'dotenv'; | |
// pulls in and sets our environment variables from a .env file | |
dotenv.config(); | |
// connect mongoose | |
mongoose.connect(process.env.MONGO_URL, { useNewUrlParser: true }); | |
// | |
export const db = mongoose.connection; | |
db.on('error', console.error.bind(console, 'connection error:')); | |
db.once('open', function() { | |
// we're connected! | |
console.log('mongo connected'); | |
}); | |
export default mongoose; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment