[IndexedDB] better way of deleting records

>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 UTC