-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongofile.js
35 lines (27 loc) · 865 Bytes
/
mongofile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module.exports = function (uri, mongoose) {
// connection settings for mongoose
mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true });
var db = mongoose.connection;
db.on('error', function (err) {
console.log('During the connection the following error occurred ', err);
});
db.on('open', function () {
console.log('Open Connection');
});
db.on('connected', function () {
console.log('We are connected');
});
db.on('disconnect', function (err) {
console.log('You have been logged out', err);
});
db.on('disconnect', function (err) {
console.log('You have been logged out', err);
});
process.on('SIGINT', function () {
mongoose.connection.close(function () {
console.log('Your application has been closed and unplugged');
process.exit(0);
});
});
return mongoose;
}