W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2010

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

From: Kris Zyp <kris@sitepen.com>
Date: Mon, 08 Nov 2010 16:40:54 -0700
Message-ID: <4CD88A86.3000006@sitepen.com>
To: Keean Schupke <keean@fry-it.com>
CC: Jonas Sicking <jonas@sicking.cc>, "Tab Atkins Jr." <jackalmage@gmail.com>, Webapps WG <public-webapps@w3.org>

Hash: SHA1
If you are looking for ways to shoot yourself in the foot, why not
just do:
undefined = true;
Storing undefined is not an important use case, practical usage is far
more important than optimizing for edge cases just because you can
think of them.

On 11/8/2010 4:33 PM, Keean Schupke wrote:
> 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
> <mailto: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

- -- 
Kris Zyp
(503) 806-1841
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
Received on Monday, 8 November 2010 23:43:42 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:28 UTC