forked from cboard-org/cboard-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
26 lines (22 loc) · 685 Bytes
/
Copy pathdb.js
File metadata and controls
26 lines (22 loc) · 685 Bytes
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
'use strict';
var mongoose = require('mongoose');
var config = require('./config');
const seeds = require('./seeds');
mongoose.connect(config.databaseUrl, { useNewUrlParser: true });
mongoose.connection.on('connected', () => {
console.log('Connected to ' + config.env + ' database ');
seeds();
});
mongoose.connection.on('error', err =>
console.log('Database connection error: ' + err)
);
mongoose.connection.on('disconnected', () =>
console.log('Disconnected from database')
);
process.on('SIGINT', () =>
mongoose.connection.close(() => {
console.log('Finished App and disconnected from database');
process.exit(0);
})
);
module.exports = mongoose.connection;