Accessing the database is asynchronous. Although you haven't provided any code (please do so in the future with any posts regarding issues), I'm guessing you're returning the array without waiting for the SQLite query to complete.
I'm going to suggest promises for this -- life is much simpler with them. I use Q (
https://github.com/kriskowal/q), but there are lots of great libraries out there (or ES6 has them natively, but you'll have to transpile from ES6-->ES5).
Then you can do something like this (this was quick, so I can't promise it isn't without error):
doQuery = function doQuery(db, sqlText, sqlBinds) {
var deferred = Q.defer();
db.transaction( function gotTransaction(tx) {
tx.execute(sqlText, sqlBinds,
function gotResults (tx,results) { deferred.resolve(results); },
function gotError (tx, err) { deferred.reject(err); });
}
});
return deferred.promise;
};
function myFunction(db} {
return doQuery(db, "your query", [binds])
.then (function processResults® {
var retArray = [];
for (var i=0;i<r.rows.length;i++) {
retArray.push(r.rows.item(i));
}
return retArray;
});
}
myFunction(db)
.then(function(results) {
console.log(results); // logs your results (hopefully)
})
.catch(function(err) {
console.log("Error:", err);
})
.done();