How can I use IDBKeyRange bounds with IDBCursor to paginate a Firefox IndexedDB object store without rescanning the entire dataset?
0 reputation · 26 Nov 2022, 12:49 UTC
I want to page through a large dataset stored in an IndexedDB object store in Firefox, returning a fixed number of records per view. The dataset may be modified while the user navigates, so each page should reflect a consistent snapshot without rescanning the whole store for every request.
I plan to create an IDBKeyRange that defines the lower and upper bounds for the current page, open a cursor with that range, and then use cursor.continue to advance to the next page. However, I am unsure how to combine the bound with the cursor’s continuation to avoid restarting from the beginning, and what technique ensures stable pagination when records are inserted or deleted between pages.
How can I correctly set the key range for each page so that the cursor continues from where the previous page left off? What approach can I use to guarantee that each page shows a stable view of the data despite concurrent modifications?