Skip to content

Instantly share code, notes, and snippets.

@codebubb
Created April 14, 2016 22:46
Show Gist options
  • Select an option

  • Save codebubb/6035d9face7dd2d33ababe31ee3c1cbb to your computer and use it in GitHub Desktop.

Select an option

Save codebubb/6035d9face7dd2d33ababe31ee3c1cbb to your computer and use it in GitHub Desktop.
var sqlite3 = require('sqlite3').verbose();
var get_rows = function(query, callback){
var db = new sqlite3.Database('test.db');
db.serialize(function(){
db.all(query, function(err, rows){
callback(rows);
});
});
}
var get_all = function(callback){
var results = [];
var queries = ["SELECT * FROM users;", "SELECT * FROM staff;"];
get_rows(queries[0], function(rs){
results.push(rs);
get_rows(queries[1], function(rs){
results.push(rs);
callback(results);
});
});
}
get_all(function(data){
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment