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: Keean Schupke <keean@fry-it.com>
Date: Mon, 8 Nov 2010 21:41:15 +0000
Message-ID: <AANLkTi=jPS4efv6M2DnfYFroLE0FcvMt9n8Gj20-SrM6@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Webapps WG <public-webapps@w3.org>
What is the use case for storing undefined in an object-store?


Cheers,
Keean.

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

> On Mon, Nov 8, 2010 at 12:02 PM, Keean Schupke <keean@fry-it.com> wrote:
> > Hi,
> >
> >> > I don't understand that.
> >> > with the proposal, undefined clearly means the entry does not exist as
> >> > there is no way to put an undefined into the object store (as
> >> > .put(undefined, key) deletes the entry).
> >>
> >> The confusing part is that a function called 'put' actually deletes
> >> something, especially since we also have a 'delete' function.
> >
> > Sure, you could get rid of the delete function :-) I think the meaning of
> > "put(undefined, key)" is pretty clear.
>
> I guess we'll have to agree to disagree on that one :)
>
> My concern with something like this is that we'll see code do stuff like:
>
> function myStoreFunction(objectStoreName, key, value) {
>  os = db.transaction([objectStoreName]).objectStore(objectStoreName);
>  if (value === undefined) {
>    os.put(null, key);
>  }
>  else {
>    os.put(value, key);
>  }
> }
>
> which does not seem like a net win for anyone.
>
> >> I would put the question this way: What problem are you trying to
> >> solve? If the problem is that people can't store "undefined" and then
> >> tell "undefined" apart from "not there" then your proposal doesn't
> >> solve that problem as "undefined" can't be stored at all.
> >
> > Precisely, the solution I am proposing is based on disallowing storing of
> > 'undefined'. What does it mean to store 'undefined' anyway? People can
> still
> > use null.
>
> Wait, your solution doesn't solve the above described problem. The
> described problem was
>
> People can't store "undefined" and then tell "undefined" apart from
> "not there" then your proposal doesn't solve that problem as
> "undefined" can't be stored at all.
>
> Your solution doesn't solve that problem.
>
> / Jonas
>
Received on Monday, 8 November 2010 21:41:51 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:41 GMT