-
-
Save Bigous/f5773e9617000fc6692c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
exports.queryAll = function(conn, sql, args, cb) { | |
var allRows = []; | |
conn.execute(sql, args, { | |
resultSet: true | |
}, function(err, result) { | |
if (err) return cb(err); | |
function fetch() { | |
var max = 50; | |
result.resultSet.getRows(max, function(err, rows) { | |
if (err) return cb(err); | |
allRows.push(rows); | |
if (rows.length === max) { | |
fetch(); | |
} else { | |
result.resultSet.close(function(err) { | |
if (err) return cb(err); | |
cb(null, Array.prototype.concat.apply([], allRows)); | |
}); | |
} | |
}); | |
} | |
fetch(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment