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

On Mon, Nov 8, 2010 at 10:41 AM, Keean Schupke <keean@fry-it.com> wrote:
> Hi,
> In code, if:
> idbObjectStoreSync.put(key, undefined)  does the same as
>  idbObjectStoreSync.remove(key)
> then
> idbObjectStoreSync.get(key) can safely return undefined for no such key
> exists.
>
> Consider:
> idbObjectStoreSync.put('mykey', undefined); // deletes the object stored
> under mykey or noop.
> idbObjectStoreSync.get('mykey'); // returns 'undefined'
> idbObjectStoreSync.put('mykey', myobject);
> idbObjectStoreSync.get('mykey'); // returns 'myobject'
> idbObjectStoreSync.put('mykey', undefined); // deletes the object stored
> under mykey or noop.
> idbObjectStoreSync.get('mykey'); // returns 'undefined'

Indeed. But I think this is more unexpected and confusing than having
.get() return the same thing if the entry exists as if it contains
undefined.

/ Jonas

Received on Monday, 8 November 2010 18:48:21 UTC