Re: [IndexedDB] Interaction between transactions and objects that allow multiple operations

On 5/5/2010 11:44 AM, Jeremy Orlow wrote:
> On the other hand, a lot of even the most basic tasks probably should be
> done within a transaction.  But if the easiest way to do something is to
> just run it outside of a transaction, I'm guessing a good portion of users
> (including tutorial websites, people giving advice on forums, etc) will just
> do it that way.  Mandating transactions forces users to be cognizant of
> them.  Maybe that's a good thing...
To be clear, I'm not disagreeing with that.  Mozilla would really love 
to reduce the amount of async steps to do anything with a database. 
Right now, to get something from an object store, we have three steps:
1) open database; wait for callback
2) open object store; wait for callback
3) get from object store; wait for callback

Adding the transaction stuff would result in four steps:
1) open database; wait for callback
2) open transaction; wait for callback
3) open object store; wait for callback
4) get from object store; wait for callback

Maybe we can get rid of this additional step by giving a transaction to 
the consumer immediately available after the call to open, and have a 
property on the connection to access the current transaction.  But that 
might complicate things more too.

This is complicated by the fact that each step blocks similar operations 
(can only open a database when another one is not in the process of 
opening, same with object stores, etc).  This problem goes away with my 
proposal in the past [1], but I'm not sure we have consensus on it (or 
the event based approach for that matter).

Cheers,

Shawn

[1] http://lists.w3.org/Archives/Public/public-webapps/2010JanMar/0961.html

Received on Wednesday, 5 May 2010 19:55:01 UTC