Okay, I found out WebSQL doesn't work with async.waterfall()
for some reason. The following code, using async.series()
, works fine. Also when you wrap the function transaction()
around a waterfall()
it doesn't work.
Still, waterfall()
would be nice in some cases...
Working example with series()
inside transaction()
:
db.transaction(function(tx) {
async.series([
function(callback) {
tx.executeSql('DROP TABLE IF EXISTS colors', [],
function(tx, rs) { callback(null, rs); },
function(err) { callback(err); });
},
function(callback) {
tx.executeSql('CREATE TABLE IF NOT EXISTS colors (name, red, green, blue)', [],
function(tx, rs) { callback(null, rs); },
function(err) { callback(err); });
},
function(callback) {
tx.executeSql('INSERT INTO colors VALUES ("red", 255, 0, 0)', [],
function(tx, rs) { callback(null, rs); },
function(err) { callback(err); });
},
function(callback) {
tx.executeSql('SELECT * FROM colors', [],
function(tx, rs) { callback(null, rs); },
function(err) { callback(err); });
}
],
function(err, results) {
if (!!err) { onError(err); }
console.debug(results[3].rows.item(0));
});
});