0
Personal how do I amaze, data that is in the database, in an array, with NODE.js?
I have this value this values in the database:
Column 1
(linha 1)Fortaleza – Caucaia |(linha 2)
Fortaleza – Maracanau
Column 2
1(custo da viagem(linha 1)) | 6(tempo da viagem(linha 2))
And I’m pulling from the comic book with this code the result with the Node.js:
bd_select.js
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "bd_pops"
});
con.connect(function(err) {
if (err) throw err;
con.query("SELECT * FROM tb_pops", function (err, result, fields) {
if (err) throw err;
console.log(result);
});
});
So I want to store this data, from each column, inside the arrays, which are inside the script of the.html model file, which is route[] and metrica[]. Can anyone help?
The
result
is already the very object that you expect. But this "structure" that you tried to explain in the question is very confused! By the way, I realized that you copied this example. Just check the console demonstrated that will understand. Incidentally,result
is a object, not specifically a object of the Array class.– LipESprY
Yes I copied and adapted it. But when I pull it from the BD it appears the result on the console. And the first time I’m using Node.js! But obg by guidance on the result.
– Moises Moraes