0
I would like to take for example all the names of a database table and save in an array(or matrix) and then list in an html table
how can I create a new method
BS: I have that part ready:
var mysql = require('mysql');
class Dao {
  constructor() {
  }
  conectaBanco() {
    var con = mysql.createConnection({
      host: "localhost",
      port: "3307",
      user: "root",
      password: "usbw",
      database: "amor"
    });
    return con;
  }
  executaSql(sql) {
    var conector = this.conectaBanco();
    conector.connect(function(err) {
      if (err) throw err;
      console.log("Connected!");
      conector.query(sql, function(err, result) {
        if (err) throw err;
        console.log(result);
      });
      conector.end();
    });
  }
}
var dao = new Dao();
dao.executaSql("select * from nomes");
module.exports = new Dao();
But the
resultinside the callback is already an array.– Augusto Vasques
What gives you that
console.log(result);?– Sergio