How to show 'Finish'
after screening all row.name
results ?
npmSql.query("SELECT name FROM sqlTable", function(err, rows, fields) {
rows.forEach(function(row) {
console.log(row.name);
});
}, function () { console.log('Finish'); });
I was trying to follow some answers like Node.js - Using the async lib - async.foreach with object but had no luck :(
Update
function abc() {
npmSql.query("SELECT name FROM sqlTable", function(err, rows, fields) {
rows.forEach(function(row) {
console.log(row.name);
});
}, function () { console.log('Finish'); });
}
Put the console.log('Finish')
statement after the forEach
call:
npmSql.query("SELECT name FROM sqlTable", function(err, rows, fields) {
rows.forEach(function(row) {
console.log(row.name);
});
console.log('Finish');
});
You're using the standard javascript Array.prototype.forEach
, which is synchronous. The question you linked deals with an unrelated async foreach
function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With