forked from karan/ZipUp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
33 lines (26 loc) · 901 Bytes
/
Copy pathdb.js
File metadata and controls
33 lines (26 loc) · 901 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
27
28
29
30
31
32
33
// Established database connection
var mongoose = require('mongoose');
var dbURI = 'mongodb://heroku_app23454617:c6igkhqe6ojpv02um4v0v812ut@ds035617.mongolab.com:35617/heroku_app23454617';
mongoose.connect(dbURI);
// when connected with db
mongoose.connection.on('connected', function() {
console.log('Connected to db ' + dbURI);
});
// some error when connecting
mongoose.connection.on('error', function(err) {
console.log('Connection error: ' + err);
});
// disconnected from db
mongoose.connection.on('disconnected', function() {
console.log('Disconnected from DB.');
});
// If the Node process ends, close the Mongoose connection
process.on('SIGINT', function() {
mongoose.connection.close(function() {
console.log('Disconnected from DB by app.');
process.exit(0);
});
});
// bring in all models
require('./models/bathroom');
require('./models/review');