salix/services/mailer/application/database.js

25 lines
622 B
JavaScript
Raw Normal View History

2017-05-30 06:06:14 +00:00
var mysql = require('mysql');
var settings = require('./settings.js');
2017-05-30 06:06:14 +00:00
module.exports = {
2017-05-30 06:06:14 +00:00
/**
* Variable de instancia del pool
*/
pool: null,
/**
* Iniciar pool de conexión con la base de datos
*/
init: function() {
this.pool = mysql.createPool(settings.mysql());
2017-05-30 06:06:14 +00:00
this.pool.getConnection(function(error, connection) {
if (error) {
2017-06-07 13:28:42 +00:00
throw new Error('Can\'t connect to database: ' + error.code);
} else if (settings.app().debug) {
console.log('Database connection stablished');
2017-05-30 06:06:14 +00:00
}
});
}
};