Re: IDBObjectStore/IDBIndex.exists(key)

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)
>
> Makes any sense?

We can't make any database operations synchronous since that require
synchronous IO which is really bad for perf. It's also different from
all other database operations. So if that's your request then the
answer is definitely no.

/ Jonas


> 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:22:35 UTC