if (typeof wait.counter == 'undefined' ) {
Checking if something is undefined by checking it's type is unnecessary. Since undefined is a falsey value, simply putting the thing you'd like to check in a conditional will do the trick:
if( !wait.counter ) {
console.log ("count= " + ++(wait.counter) + " queryComplete= " + queryComplete);
All those + signs between "count= " and " queryComplete= " are a little confusing. It seems like you tried to make it more readable by putting ()s around wait.counter, but it would be more readable if you just moved ++wait.counter to a line of it's own.
++wait.counter;
console.log ("count= " + wait.counter + " queryComplete= " + queryComplete);
Thanks to IsmaelMiguel for recommending to move the ++wait.counter out of console.log all together.
Add some documentation to your functions to describe what they are doing, what they need, why they need it, and what it is returning.
This is all I can review, as I am not familiar with SQL.
P.S.
fixed = true;
break;