Created
April 13, 2020 10:45
-
-
Save sdejean28/95035b4652bb46c20b04d9d7fe2490bf 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
const mongoose = require('mongoose') | |
var notifier = require('./notifier.js') | |
mongoose.connection.on('connected', () => { | |
notifier.emit('mongodb_connected'); | |
}); | |
mongoose.connection.on('error', () => { | |
setTimeout(function () { | |
notifier.emit('mongodb_connect'); | |
}, 1000) | |
}); | |
notifier.on('mongodb_connect', () => { | |
mongoose.connect('mongodb://mongodb/db', { | |
useNewUrlParser: true, | |
useCreateIndex: true, | |
useFindAndModify: true, | |
useUnifiedTopology : true | |
}) | |
}); | |
// startup - first try | |
notifier.emit('mongodb_connect'); | |
module.exports = { | |
mongoose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment