W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2013

[IndexedDB] better way of deleting records

From: Kyaw Tun <kyawtun@yathit.com>
Date: Wed, 16 Jan 2013 11:19:41 +0800
Message-ID: <CAFPCW95HdGc0QTCJVz9r_WuEnMFs0Tpt_4eh-fuD0fArmnKxDA@mail.gmail.com>
To: public-webapps@w3.org
>From developer point of view, IDBObjectStore.delete method cannot be used
directly in most use case, since IDBObjectStore.delete returns
undefined. IDBObjectStore.delete(random_key) always receives onsuccess
event, but nothing happen. Currently I use cursor or count method before
deleting to make sure that it will actually be deleted. My suggestion is
IDBObjectStore.delete return number of records deleted
and IDBObjectStore.clear return undefined. Hence IDBObjectStore.clear will
take optional key or key range.

There is no efficient way to delete records by secondary key or index
key. IDBIndex do not have delete methods. Currently we have to use
openCursor and delete one by one. Interestingly again, we cannot delete
with more efficient openKeyCursor. Deleting from openKeyCursor should be
allowed.
Received on Wednesday, 16 January 2013 03:20:08 GMT

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