-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongo.js
More file actions
31 lines (27 loc) · 742 Bytes
/
mongo.js
File metadata and controls
31 lines (27 loc) · 742 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
/**
* A custom library to establish a database connection
*/
'use strict';
var mongoose = require('mongoose');
mongoose.Promise = require('bluebird');
var db = function() {
return {
/**
* Open a connection to the database
* @param conf
*/
config: function() {
var uri = '';
uri = 'mongodb://' + '127.0.0.1' + '/' + 'TG';
mongoose.connect(uri);
var db = mongoose.connection;
db.on('error', function callback() {
console.log('something error');
});
db.once('open', function callback() {
console.log('open success');
});
}
};
};
module.exports = db();