I am new to learning node, so sorry for a noob question. I have mysql running and stored proc returning fields. I want to assign the values to string variables and loop through each row. I do this alot in c#, but I am too much of a noob on node.
The results in the console are.
console.log(one) ->
[RowDataPacket {
CitySearchSearchEngineID: 1,
SearchURL: 'https://www.url.com' } ]
OkPacket {
fieldCount: 0,......
}
This above is good, however,
console.log(one.SearchURL); -> undefined
I have been struggling with this for a while now and can't figure out why I can't get the value out. I have tried a handful of different methods. If I do JSON.stringify it will give the row to a string just fine.
Any ideas would be appreciated.
Code below.
var db = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'secretpassword',
database: 'DB1',
port: 3306
});
db.connect(function(err){
if(err){
console.log('Error connecting to Db');
return;
}
console.log('Connection established');
});
db.query('CALL esp_Select_SearchURLs()', function(err, rows){
if(err) throw err;
_.each(rows, function(one){
console.log(one);
console.log(one.SearchURL);
});
});
via StevenG
No comments:
Post a Comment