var mysql = require('mysql'); let settings = require('./settings.js'); module.exports = { /** * Pool instance */ pool: null, /** * Start database pool */ init: function() { this.pool = mysql.createPool(settings.mysql()); this.pool.getConnection(function(error, connection) { if (error) { throw new Error('Can\'t connect to database: ' + error.code); } else if (settings.app().debug) { console.log('Database connection stablished'); } }); }, /** * Set test environment mail. */ testEmail: function() { this.pool.query('SELECT fakeEmail as email FROM vn.config', function(error, qryRs) { settings.testEmail = qryRs[0].email; }); } };