Hello, I'm having an error in the MSSQL module of nodejs for connections to SQL Server. The connection is normal, the problem is time to perform the query, the function does not return anything to the callback.
Connection code:
var sql = require('mssql');
var config = {
user: 'user',
password: 'password',
server: 'ip',
database: 'database',
connectionTimeout: '5000',
requestTimeout: '5000',
options: {encrypt: true}
};
var pool = function(){
var conn = new sql.Connection(config, function(err){
var request = new sql.Request(conn);
//console.dir(request);
return request;
});
return conn;
}
module.exports = function(){
return pool;
}
DAO:
function CampanhaDAO(connection){
this._connection = connection;
//console.log(this._connection)
}
CampanhaDAO.prototype.getCampanhas = function(){
var sql = "SELECT * FROM notificacao_campanha";
this._connection.query(sql, function(err, recordset){
console.log(recordset);
});
};
module.exports = function(){
return CampanhaDAO;
};