I'm using node.js for a project, and I have this certain structure in my code which is causing problems. I have an array dateArr
of sequential dates that contains 106 items. I have an array resultArr
to hold resulting data. My code structure is like this:
function grabData(value, index, dateArr) {
cassandra client execute query with value from dateArr {
if (!err) {
if (result has more than 0 rows) {
process the query data
push to resultArr
}
if (result is empty) {
push empty set to resultArr
}
}
}
}
dateArr.forEach(grabData);
I logged the size of resultArr
after each iteration and it appears that on some iterations nothing is being pushed to resultArr
. The code completes with only 66 items stored in resultArr
when 106 items should be stored because the I/O structure between dateArr
and resultArr
is 1 to 1.