This is the following I tried to search but I did not find any solution, so I tried to create a function in the model of my application that will return the data of the query in the database. This function would be called in my controller which would later be sent to the page file.
Query function
exports.show = function(){
var result;
connection.getConnection(function(err, connection){
connection.query('select 1 + 1 as teste', function(err, rows){
this.result = rows[0].teste;
connection.release();
console.log('---->', this.result);
return this.result;
});
});
};
Controller
var Model = require('../models/Models');
exports.Index = function(request, response){
response.pageInfo = {};
response.pageInfo.title = 'Users';
response.pageInfo.users = Model.show();
response.render('user/index', response.pageInfo);
};
And the .jade page
extends ../layout
block content
h1 #{users}
And by running that way it just does not print the value on the page, but it works on the console.