marcuswestin / store.js

Cross-browser storage for all use cases, used across the web.
MIT License
14.01k stars 1.33k forks source link

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

Open davidrapin opened 7 years ago

davidrapin commented 7 years ago

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

marcuswestin commented 7 years ago

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

AaronLlanos commented 7 years ago

@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

marcuswestin commented 7 years ago

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:

I'd love input on this!

AaronLlanos commented 7 years ago

@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?

imerkle commented 7 years ago

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