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

-----BEGIN PGP SIGNED MESSAGE-----
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.
Kris

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
SitePen
(503) 806-1841
http://sitepen.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
iEYEARECAAYFAkzYioUACgkQ9VpNnHc4zAxceQCeI7SF6MWWHDikmbtFECy4wKBd
pWMAoKThBuiaXg0V1rM7nYh0abp6t7SU
=2FSo
-----END PGP SIGNATURE-----

Received on Monday, 8 November 2010 23:43:42 UTC