Re: [IndexedDB] Behavior of IDBObjectStore.get() and IDBObjectStore.delete() when record doesn't exist

If more than one developer are working on a project, there is no way I can
know if the other developer has put 'undefined' objects into the store
(unless the specification enforces it).

So every time I am checking if a key exists (maybe to delete the key) I need
to check if it _really_ exists, or else I can run into problems. For
example:

In module A:
put(undefined, key);

In module B:
if (get(key) !== undefined) {
   remove(key);
}

So the object store will fill up with "key = undefined" until we run out of
memory.


Cheers,
Keean.


On 8 November 2010 23:24, Jonas Sicking <jonas@sicking.cc> wrote:

> On Mon, Nov 8, 2010 at 3:18 PM, Keean Schupke <keean@fry-it.com> wrote:
> > Let me put it another way. Why do you want to allow putting 'undefined'
> into
> > the object store? All that does is make the API for get ambiguous. What
> does
> > it gain you? Why do you want to make 'get' ambiguous?
>
> It seems like a loose-loose situation to prevent it. Implementors will
> have to add code to check for 'undefined' all the time, and users of
> the API can't store 'undefined' if they would like to.
>
> > I think having an unambiguous API for 'get' is worth more than being able
> to
> > 'put' 'undefined' values into the object store.
>
> Can you describe the application that would be easier to write,
> possible to write, faster to run or have cleaner code if we forbade
> putting 'undefined' in an object store?
>
> / Jonas
>

Received on Monday, 8 November 2010 23:34:31 UTC