Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose = require('mongoose');
- var logger = require('./logger');
- var config = require('../config/config.json');
- module.exports = {
- connect: function (callback) {
- // Open DB connection to database.
- mongoose.connect(config.database.host, config.database.name);
- /*
- * Database checks.
- */
- mongoose.connection.on('error', function (error) {
- logger.info('Connection error: ' + error, {
- module: 'Db'
- });
- callback(error);
- });
- mongoose.connection.once('open', function () {
- logger.info('Connection opened.', {
- module: 'Db'
- });
- callback(null);
- });
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment