Created
April 14, 2016 22:46
-
-
Save codebubb/6035d9face7dd2d33ababe31ee3c1cbb 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
| 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