So I'm really digging using localStorage for web apps and it works great... if you need a key-value store. However, I also find that my storage needs include something that looks like database t开发者_运维问答ables with primary key - foreign key relationships. I had hoped IndexedDB would shape up sooner, but I'm disheartened by the less-than-ideal solution for doing joins (see example 4).
I've been tempted to write a B+ tree backed by localStorage and deal with the indexing and joining myself; however, I feel that may be overkill for two reasons:
- It's reinventing the wheel, and likely to do it poorly.
- It's never going to reach the performance of a B+ tree implemented at the file level.
I've already read a ton of criticism of the IndexedDB API (again, mostly for the roll-your-own join operation). So, my question is, is there an API that's supported across the major browsers for storing tabular-ish data locally (like localStorage) that's specifically geared for correlating via indexes?
Just to set the tone here, let me be clear: I'm not really looking for a silver-bullet answer. I'm more looking to understand a little clearer what the state of the art is.
The "criticism against IndexedDB" isn't as much of a problem now that your question is celebrating its one year anniversary today. As for state-of-the-art, it's hard to say. Web SQL has a more solid API but it is just a relational db. IndexedDB is a little newer to the game but it's garnering more and more support. The nice thing about indexedDB is that you can store your objects directly (and index properties, etc) whereas Web SQL will make you translate between a result set and your objects and visa-versa.
精彩评论