IDBObjectStore require openKeyCursor method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

IDBObjectStore require openKeyCursor method

Kyaw Tun
In contrast to IDBIndex, IDBObjectStore does not have openKeyCursor method. This method fetch list of keys of a given range without cost of serialization. There is no other ways to iterate keys only from IDBObjectStore. However efficient fetching of keys in a specific range is required in high performance web app. 

Use case 1: Suppose 'note' object store use in-line key 'title' (possibly adding a nonce). Developer wish to list titles without retrieving full records.

Use case 2: Suppose 'article' object store use array keys having first element as author id, which is key to 'author' object store and second element as time stamp. Efficient retrieval of list of articles by an author is possible by fetching IDBKeyRange.bound([author_id], [author_id, 0]) by indexing primary key.  

Use case 3: I am developing IndexedDB database wrapper, which use key scanning to run join algorithm with sorting and constrain. Sometimes, the use case require iterating of primary key. 

The workaround suggested in use case 2, it not applicable for out-of-line key. Also indexing primary key is conter intuitive.

Since primary key will already have indexed in the database engine, openKeyCursor method should provide in IDBObjectStore object. At the same time, we get consistance and symmetric API.   

Best regards,
Kyaw 
Reply | Threaded
Open this post in threaded view
|

Re: IDBObjectStore require openKeyCursor method

Joshua Bell-3
On Mon, Nov 12, 2012 at 6:22 AM, Kyaw Tun <[hidden email]> wrote:
In contrast to IDBIndex, IDBObjectStore does not have openKeyCursor method. This method fetch list of keys of a given range without cost of serialization. There is no other ways to iterate keys only from IDBObjectStore. However efficient fetching of keys in a specific range is required in high performance web app. 

+1 to adding IDBObjectStore.openKeyCursor in a future version of the IDB spec. The Chromium implementation ends up with an internal version of this for performance reasons as well.