[whatwg] Asynchronous database API feedback

Can you help me understand the problem you're pointing out? The
difference between the idea outlined and the current spec is the
absence of the transaction callback, but it basically (I think) has
the equivalent net effect.

db.createTransaction is just a mutable list of statements until the
execute method is called. In fact, it could even probably be just a JS
array.

tx.execute(..) immediately returns, then asynchronously (pardon the
sketchiness):
* opens transaction
* calls optional errorCallback if fails
* proceeds to execute statements in queue
* calls optional successCallback upon success.

I don't see it as being too much different from the spec's transaction
steps. In fact, I can easily see this written as a JS wrapper around
the current spec.

:DG<

On Dec 12, 2007 12:33 PM, Brady Eidson <beidson at apple.com> wrote:
> I think the issue you're forgetting is when opening a transaction can
> fail.  The transaction callback is only called when the transaction is
> successfully opened and you know that it is starting out valid.
>
> ~Brady
>
>
> On Dec 12, 2007, at 9:37 AM, Dimitri Glazkov wrote:
>
> > .. 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 11:18:56 UTC