I use this code get all entries from the "users" table in a sqlite3 library in nodejs. When I check the value rows inside the function it is defined, but the calling function only gets an undefined object.
exports.getUsers = function() {
exports.getDb().serialize(function() {
exports.getDb().all('SELECT * FROM users', function(err, rows) {
if(err !== null) {
winston.error(err);
}
return rows !== undefined ? rows : [];
});
});
};