axemclion / jquery-indexeddb

An IndexedDB Plugin for Jquery.
Other
195 stars 71 forks source link

Leveraging cursor.advance() when iterating over an index or objectStore #63

Closed scummins78 closed 10 years ago

scummins78 commented 10 years ago

I am trying to figure out how to advance the cursor further than one when using .each() for iterating through an index or objectStore (for paging purposes). What is the syntax for doing that using jquery.indexeddb?

Thanks.

axemclion commented 10 years ago

https://github.com/axemclion/jquery-indexeddb/tree/master/docs#cursorEach

Specifically

   return; 
    // false - do not continue iteration
    // integer 'n' - n can be 1,2,... indicating skip next n objects and continue
    // object - continue to item with object as the next key
    // default - no return, or undefined return, continue iteration
scummins78 commented 10 years ago

What if I wanted to jump forward a number of items and continue iterating (ie. a datastore with 100 items, I would like to iterate over items 90 - 100 and skip the first 80). I have tried just leveraging the each and skipping items until I get to the 90th item, but this doesn't scale well when I hit the > 10,000 item mark? Looking at the indexeddb documentation I was thinking I could leverage something like IDBCursor.advance(90).

https://developer.mozilla.org/en-US/docs/Web/API/IDBCursor.advance

Thanks.

scummins78 commented 10 years ago

Nevermind, misread :) Thanks for your help.