0
I’m having trouble getting the result of a query in Nodejs bd -Sqlserver module - mssql
Error presented:
Typeerror: Cannot read Property 'query' of Undefined At formulasdao.getFormulas (C: xampp htdocs node_fa app models Formulasdao.js:6:22)
dbConnection.js
const sql = require('mssql');
var config = {
user: 'user',
password: 'password',
server: 'ip',
database: 'name_db',
connectionTimeout: '5000',
requestTimeout: '5000',
options: {encrypt: true}
};
var pool = function(){
var conn = new sql.ConnectionPool(config, function(err){
var request = new sql.Request(conn);
//console.dir(request);
return request;
});
return conn;
}
module.exports = function(){
return pool;
}
Formulasdao.js
function FormulasDAO(connection) {
this._connection = connection;
}
FormulasDAO.prototype.getFormulas = (callback)=>{
this._connection.query('select * from usuario', callback);
}
module.exports = function() {
return FormulasDAO;
}