knadh / localStorageDB

A simple database layer for localStorage and sessionStorage for creating structured data in the form of databases and tables
http://nadh.in/code/localstoragedb
814 stars 128 forks source link

ability to use other Storage objects #10

Closed asgraf closed 11 years ago

asgraf commented 11 years ago

I think it would be a good idea to add an option to choose other storage object to work with. I would like to use localStorageDB with sessionStorage object or Firefox's simpleStorage object instead of hardcoded localStorage object. Of course localStorage should be default object to use if no replacement object provided.

knadh commented 11 years ago

sessionStorage support is a good suggestion. Since the localStorage and sessionStorage APIs are virtually identical, it shouldn't be a problem adding support. I'll push an update out pretty soon.

Firefox's simple-storage, however, I think is outside the scope of the lib as it's Firefox's own implementation confined to its plugin architecture, and not really for the web.

asgraf commented 11 years ago

I mean the ability to pass any arbitrary object with localStoragelike API for use with your localStorageDB library. No matter if it is sessionStorage, or some kind custom made cookieStorage object or maybe some simpleStorageProxy object.

knadh commented 11 years ago

Not sure if that's a good idea, accepting unknown objects and assuming they have localStorage-like APIs. That would be bad design on the library's part, and not reliable enough for production. Of course, the library itself is simple, one could modify it to make it work with any storage object quite easily.