[IndexedDB] Existence checking

Hi all.

I have a query/suggestion regarding the current spec for IndexedDB.
Currently there doesn't appear to be any specific way to check
existence of things like indexes and object stores. One scenario this
may be important could be a site which allows optional offline
functionality, for example allowing a user to have an offline store
for "cars", "planes" and "boats". The offline JavaScript code would
like to query which stores were available offline.

There are a couple of ways to do this:

  * Rely on developers to do something clever with the database version
    Example: bitmask what facilities are available: 1 = car, 2 =
                   plane, 4 = boat. Database version of "3" would imply that
                   "car" and "plane" stores were available.
    Comment: This may be an approach which would be recommended if
                    the intention of the spec is for the database version to be
                    the principle identifier of the state/version of
an IndexedDB.
                    IMHO, encouraging this method would lead to confusing
                    database version numbers and in turn, a maintenance
                    nightmare.

  * Try and catch errors
    Example: Attempt to open a store, catch the appropriate exception
                  and then attempt to create the store.
    Comment: Code to do this is not particularly readable, and relies
                    on invoking an error condition to find out whether
a particular
                    store exists.

I'd much prefer to see a method to check for the existence of object
stores/indexes that doesn't rely on try/catching exceptions. An
"exists" check would lead to leaner, more readable code which doesn't
depend on exception handling to imply the state of the database.

I've not contributed here before, so please be nice if this suggestion
is stupid for reasons I don't know : )

Thanks.

Nathan

Received on Monday, 5 July 2010 14:31:42 UTC