Cleo | 00ccf36 | 2024-02-29 15:07:31 -0500 | [diff] [blame^] | 1 | const mongoose = require('mongoose');
|
| 2 |
|
| 3 | module.exports = {
|
| 4 | init: () => {
|
| 5 | mongoose.connect(process.env.MONGO_URL).catch(err => console.log(err.reason));
|
| 6 |
|
| 7 | mongoose.Promise = global.Promise;
|
| 8 |
|
| 9 | mongoose.connection.on('connected', () => {
|
| 10 | console.log('\nMongoose connection successfully opened');
|
| 11 | });
|
| 12 |
|
| 13 | mongoose.connection.on('err', err => {
|
| 14 | console.error(`Mongoose connection Error\n ${err.stack}`);
|
| 15 | });
|
| 16 |
|
| 17 | mongoose.connection.on('disconnected', () => {
|
| 18 | console.log('Mongoose connection disconnected');
|
| 19 | });
|
| 20 | }
|
| 21 | }; |