const mongoose = require('mongoose'); | |
module.exports = { | |
init: () => { | |
mongoose.connect(process.env.MONGO_URL).catch(err => console.log(err.reason)); | |
mongoose.Promise = global.Promise; | |
mongoose.connection.on('connected', () => { | |
console.log('\nMongoose connection successfully opened'); | |
}); | |
mongoose.connection.on('err', err => { | |
console.error(`Mongoose connection Error\n ${err.stack}`); | |
}); | |
mongoose.connection.on('disconnected', () => { | |
console.log('Mongoose connection disconnected'); | |
}); | |
} | |
}; |