I have a beginners question regarding node.js / javascript syntax and asynchronous calls. I'm using node-dbi to pull some information out of a MySQL Server.
I have 2 tables. Client and Zone.
I need to write a function that does this:
for (i=0;<zone.count;i++){
for (j=0;j<client.count;j++){
//loop through the entire client table for each zone record & run a condition
}
}
Here is what my syntax in node-dbi looks like:
db.fetchAll('SELECT * from Zone', null, function(err, result){
if (result) {
db.fetchAll('SELECT * from Client', null, function(err, result){
if (result) {
//do something to all client records for each zone record
}
});
}
});
As it's immediately obvious, my result and err variables are clashing.. Can someone please explain the syntax to solve this asynchronous function?
Thanks!