DEV Community

Discussion on: Don’t pay the for-loop tax

Collapse
 
lluismf profile image
Lluís Josep Martínez

Do you mean in JS or Java? Because in Java doing it the functional way is extremely complex according to stackoverflow.com/questions/322092...

Do you have a JS example that reads rows from a relational DB without using loops?

Thread Thread
 
danhomola profile image
Dan Homola

I meant JavaScript. An example could be Google Lovefield (haven't tried it though).

Thread Thread
 
lluismf profile image
Lluís Josep Martínez

By looking at the Readme, it seems like this API returns an array of rows. Which obviously is not acceptable when dealing with huge result sets.

}).then(function(results) {
// The SELECT query's Promise will return array of rows selected.
// If there were no rows, the array will be empty.

results.forEach(function(row) {
// Use column name to directly dereference the columns from a row.
console.log(row['description'], 'before', row['deadline']);
});
});