W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2007

[whatwg] Asynchronous database API feedback

From: Dimitri Glazkov <dimitri.glazkov@gmail.com>
Date: Wed, 12 Dec 2007 11:37:44 -0600
Message-ID: <fb15ac210712120937y25aac4b4lac9c02e2ee05f368@mail.gmail.com>
.. Speaking of batches, in my adventure of implementing the new SQL
spec, it looked like the transaction callback is mostly a functional
equivalent of a queue.

So, one idea would be explicitly make it an queue-like structure,
rather than a function callback:

var db = openDatabase('test');
var tx = db.createTransaction();
tx.add(db.sql('create table if not exists chickadees(name text, kind text)'));
tx.add(db.sql('insert into chickadees values(?, ?)', ['moesha',
'black-capped']));
tx.add(db.sql('select * from chickadees', [], function(rs) {
console.log(rs.rows.name); }));
tx.execute(function(error) {
	console.log('bird flip!');
});

.. in which case single statements could be executed as:

db.sql('select count(*) as count from chickadees', [], function(rs) {
console.log(rs.rows.count); }).execute();

What do you think?

:DG<
Received on Wednesday, 12 December 2007 09:37:44 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:38 UTC