W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2009

Re: [WebDatabase] Database interface (vs. DatabaseSync interface)

From: Nikunj R. Mehta <nikunj.mehta@oracle.com>
Date: Mon, 27 Jul 2009 13:14:39 -0700
Cc: Aaron Boodman <aa@google.com>, public-webapps WG <public-webapps@w3.org>
Message-Id: <29316A73-24D6-43D7-B291-88E9B392C8C0@oracle.com>
To: Maciej Stachowiak <mjs@apple.com>

On Jul 27, 2009, at 12:54 PM, Maciej Stachowiak wrote:

> On Jul 27, 2009, at 12:55 PM, Nikunj R. Mehta wrote:
> <snip>

> JavaScript actually lets you write a series of nested callbacks in a  
> way that looks almost like straight-line code, by using function  
> expressions:
> db.transaction(function(tx) {
>     tx.executeSQL("SELECT UserID FROM Users WHERE UserName = ?",  
> [userToBan], function(tx, firstResultSet) {
>         if (resultSet.rows.length > 0) {
>             tx.executeSQL("INSERT INTO BannedUsers VALUES (?)",  
> resultSet.rows[0]);
>         }
>     }
> });
> (Sorry for the contrived example and my likely syntax errors.)
> Granted, this gets awkward if your logic gets considerably more  
> complicated.

And mine did get awkward, very quickly. I found it really hard to keep  
myself sane through the development of asynchronous code that executes  
transactionally and involves multiple sql statements.

My argument is that the program logic gets really complex, really fast  
if you are doing anything complex using Database. On the other hand,  
if your logic and SQL needs are really simple, you might as well use  
the DatabaseSync interface and pay the price of marshaling and  
unmarshaling, which may not be that much.

Alternatively, perhaps, we should consider doing something in  
WebWorkers to deal with the overhead of sharing JavaScript objects  
across VMs.

Received on Monday, 27 July 2009 20:17:09 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:18 UTC