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

On Wed, May 5, 2010 at 8:56 PM, Shawn Wilsher <sdwilsh@mozilla.com> wrote:

> 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.
>

I'd also worry that if creating the transaction were completely transparent
to the user that they might not think to close it either.  (I'm mainly
thinking about copy-and-paste coders here.)

To be honest, while gross, I don't think 4 steps is _that_ much worse then 3
steps and I still think Pablo's option c is the best one.


> 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).
>

Not sure about Microsoft/Pablo, but you've got my support.

I'm definitely convinced that what's currently specced is not adequate.  I
was leaning towards a callback based interface, but after discussing the
pros and cons with several developers and the fact that pretty much all the
other new APIs are going with an event based model, it seemed like the best
way to go.  So I'm actually in the process of landing a patch to switch (my
half working implementation in) WebKit over to an event based model.

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

Received on Wednesday, 5 May 2010 20:10:09 UTC