I am implementing the use of IndexedDB storage in my webapp (Chrome only) which stores a sequence of records along the lines of
{raw:"string",id:"string",dayUsed:number}
where
- id - is the unique string identifying the object (used as the indexedDB objectstore key
- dayUsed - records the last day (since Date(2013,11,10)) that the object was used.
As the app is used the number of records in this store will grow. I want to keep tabs on what is happening in this object store with a view to pruning it when
- The number of records in the store exceeeds a preset threshold
- There are records in the store with a dayUsed value exceeding a preset threshold
I have followed the MDN tutorial (which b.t.w has a few small bits of misinformation) and implemented most of what I need but the record pruning bit still seems unclear.
The core methods offered by IndexedDB are quite limited. For instance, even getting the total number of records is not just a matter of issuing a one-liner. Whilst the app is running I could from time-to-time run a cleanup routine that goes through the whole object store and deletes entries with dayUsed breahces. However, given that my objectstore could well have several hundred entries this could be a lengthy operation that slows down the app. Where then? Spawn a webworker to do the job?
This is starting to look more complicated than I had envisaged. To my question - are there high level wrappers that provide a SQL like interface to IndexedDB stores that can handle all such tasks well?