I'm trying to use sqlite3 in an expressjs app (nodejs)
I want to create a function that returns all the results from a select statement. This function will be called by a route that
var queryGetAll = 'SELECT id, title, description, modified, lat, lng, zoom FROM maps';
function Manager(){
this.db = null;
this.getAll = function(){
var all = [];
this.db.all(queryGetAll, function(err, rows){
if (err){
throw err;
}
all.push.apply(all, rows);
});
return all;
}
}
I know nodejs is asynch, so it means the return is called before the end of the query. But I don't find examples on how I should use sqlite.