store.js icon indicating copy to clipboard operation
store.js copied to clipboard

Support for async storage (IndexedDB, WebSQL, ...)

Open davidrapin opened this issue 8 years ago • 5 comments
trafficstars

IndexedDB exists in many modern browsers. I don't know about performances vs. localStorage. Support for IndexedDB would be great :)

davidrapin avatar Feb 28 '17 10:02 davidrapin

A good place to start might be looking at https://github.com/localForage/localForage and get a sense of how we'd want to do jt

marcuswestin avatar Feb 28 '17 14:02 marcuswestin

@marcuswestin it seems as though it is some minor setup, environment checks to make it happen. The calls that it makes would need to be asynchronous though. I know that you are pretty focused on keeping a synchronous project, but a simple promise shim would keep functionality for < ie8

AaronLlanos avatar Mar 02 '17 07:03 AaronLlanos

We definitely need to add an async API.

I like the idea of having a sync, localStorage backed store for more trivial key-value storage and an async indexDB backed store for larger blobs working in parallel.

I'm considering a few options:

  • store.get.async('foo').then(...) and store.set.async('foo', 'bar').then(...)
  • store.async.read('foo').then(...) or store.blobs.read/write etc

I'd love input on this!

marcuswestin avatar Mar 02 '17 23:03 marcuswestin

@marcuswestin, I think you have the right idea for a starting point. Although, I think that the async object in the library should expose 2 items: get set as opposed to the other way around. store.async.get('foo').then(...) and store.async.set('foo', 'bar').then(...) looks cleaner to me. In terms of reading/writing blobs/files why not just have this functionality put into get/set?

AaronLlanos avatar Mar 04 '17 20:03 AaronLlanos

There is a wrapper called Dexie. anyone comment on how is that ?

imerkle avatar Jun 24 '17 15:06 imerkle