W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2014

Re: IDBObjectStore/IDBIndex.exists(key)

From: Joshua Bell <jsbell@google.com>
Date: Mon, 23 Jun 2014 14:22:37 -0700
Message-ID: <CAD649j7sR5U5GTxssyiEp8xs+V0RQdXGBeTwXrs43su2sBm=jw@mail.gmail.com>
To: Marc Fawzi <marc.fawzi@gmail.com>
Cc: Jonas Sicking <jonas@sicking.cc>, ben turner <bent.mozilla@gmail.com>, Webapps WG <public-webapps@w3.org>
On Mon, Jun 23, 2014 at 1:38 PM, Marc Fawzi <marc.fawzi@gmail.com> wrote:

> No, I was suggesting .exists() can be synchronous to make it useful
>
> I referred to it as .contains() too so sorry if that conflated them for
> you but it has nothing to do with the .contains Joshua was talking about.
>
> In short, an asynchronous .exists() as you proposed does seem redundant
>
> But I was wondering what about a synchronous .exists() (the same proposal
> you had but synchronous as opposed to asynchronous)
>
>
We can do synchronous tests against the schema as it is feasible for
implementations to maintain a copy of the current schema for an open
connection in memory in the same thread/process as script. (Or at least, no
implementer has complained.)

Actually hitting the backing store to look up a particular value may
require a thread/process hop, so must be an asynchronous operation.
Actually pulling the *data* across and decoding it is an added expense,
which is why count(), the proposed exists(), and key cursors exist as
optimizations over get() and regular cursors.





> Makes any sense?
>
> Sent from my iPhone
>
> > On Jun 23, 2014, at 1:28 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> >
> >> On Mon, Jun 23, 2014 at 1:03 PM, Marc Fawzi <marc.fawzi@gmail.com>
> wrote:
> >> Having said that, and speaking naively here, a synchronous .exists() or
> .contains() would be useful as "existence" checks shouldn't have to be
> exclusively asynchronous as that complicates how we'd write: "if this
> exists and that other thing doesn't exists then do xyz"
> >
> > Note that the .contains() discussion is entirely separate from the
> > .exists() discussion. I.e. your subject is entirely off-topic to this
> > thread.
> >
> > The .exists() function I proposed lives on IDBObjectStore and IDBIndex
> > and is an asynchronous database operation.
> >
> > The .contains() function that you are talking about lives on an
> > array-like object and just does some in-memory tests which means that
> > it's synchronous.
> >
> > So the two are completely unrelated.
> >
> > / Jonas
>
Received on Monday, 23 June 2014 21:23:07 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:25 UTC