I have created a pool
of MySQL
module.exports = () => {
return mysql.createPool({
connectionLimit: 10,
host: 'localhost',
user: 'root',
password: '',
database: 'gym'
});
}
I have also made a query that shows me results
const dbConnection = require("../modelos/config.connection");
const connection = dbConnection();
connection.getConnection(function(error, conn){
if(error)
{
console.log(error);
} // consulta que muestra los datos
connection.query('SELECT SQL_CALC_FOUND_ROWS * FROM inventario LIMIT ? , ? ', [consulta.INICIO, consulta.ARTICULOS_POR_PAGINA], function(error, articulos)
{
if(error)
{
throw error;
connection.release();
res.status(500).send({message: error});
}else
{
connection.query('SELECT FOUND_ROWS() as total', function(error, result)
{
if(error)
{ throw error; }
else {
var total = result[0].total;
res.status(200).send({total})
}
}
);
})
connection.end();
My problem starts now that the console is dialing%% error.
plus another problem that says Pool is closed
.
so ... how can I do this query? since what I got from the first query I want to get the total of rows to be able to make a page based on it.
I hope someone can help me.