Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Joshua Bell
On Sat, Jun 21, 2014 at 9:45 PM, ben turner bent.mozi...@gmail.com wrote: I think this sounds like a fine idea. -Ben Turner On Sat, Jun 21, 2014 at 5:39 PM, Jonas Sicking jo...@sicking.cc wrote: Hi all, I found an old email with notes about features that we might want to put in v2.

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Joshua Bell
On Sat, Jun 21, 2014 at 7:02 PM, Marc Fawzi marc.fa...@gmail.com wrote: I think the same thought pattern can be applied elsewhere in the API design for v2. Consider the scenario of trying to find whether a given index exists or not (upon upgradeneeded). For now, we have to write noisy code

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Jonas Sicking
On Mon, Jun 23, 2014 at 9:59 AM, Joshua Bell jsb...@google.com wrote: On Sat, Jun 21, 2014 at 9:45 PM, ben turner bent.mozi...@gmail.com wrote: I think this sounds like a fine idea. -Ben Turner On Sat, Jun 21, 2014 at 5:39 PM, Jonas Sicking jo...@sicking.cc wrote: Hi all, I found an

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Marc Fawzi
Joshua, you're on, and I'll be happy to make suggestions once I've thought them through... At least to some extent :) Jonas, There is a small performance difference between them though when applied to indexes. Indexes could have multiple entries with the same key (but different primaryKey),

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Jonas Sicking
On Mon, Jun 23, 2014 at 1:03 PM, Marc Fawzi marc.fa...@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

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Marc Fawzi
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

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Jonas Sicking
On Mon, Jun 23, 2014 at 1:38 PM, Marc Fawzi marc.fa...@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

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Joshua Bell
On Mon, Jun 23, 2014 at 1:38 PM, Marc Fawzi marc.fa...@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

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-23 Thread Marc Fawzi
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.) Oh cool. So I could have a 3rd party component in

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-21 Thread Marc Fawzi
I think the same thought pattern can be applied elsewhere in the API design for v2. Consider the scenario of trying to find whether a given index exists or not (upon upgradeneeded). For now, we have to write noisy code like [].slice.call(objectStore.indexNames()).indexOf(someIndex) Why couldn't

Re: IDBObjectStore/IDBIndex.exists(key)

2014-06-21 Thread ben turner
I think this sounds like a fine idea. -Ben Turner On Sat, Jun 21, 2014 at 5:39 PM, Jonas Sicking jo...@sicking.cc wrote: Hi all, I found an old email with notes about features that we might want to put in v2. Almost all of them was recently brought up in the recent threads about IDBv2.