16

What solutions are there for queryable client-side data stores? This would be used as a temporary cache to perform basic operations like sorting and aggregating over user-selected date ranges in the client

I've found a few promising candidates, but I'm not sure what the best options are

There's also some other less-optimal options:

  • HTML5 localstorage / sessionstorage (need to build a query layer on top of this... like lawnchair or localstoragedb)
  • IndexedDB (browser compatibility)
  • Google gears (discontinued)
  • WebSQL (specification stopped)

I'd be curious to know your experiences with these options / if there are other ones that I've missed

user1424744
  • 161
  • 1
  • 5
  • 2
    You know those libraries are just wrappers around what you consider "less-optimal" solutions. You just need to pick the best wrapper which suits you. – adrian Feb 18 '13 at 22:39
  • I realize that- which is why I'm asking about people's experiences with these projects, in hopes of not reinventing the wheel (or maybe missing something that I haven't found completely) – user1424744 Feb 18 '13 at 22:50
  • 3
    why the hell is this question closed as not constructive? It's super helpful – KJW Feb 12 '14 at 01:53
  • You should also check out ForerunnerDB, it's a modern well-maintained JS database with an easy to use query language. Supports views, joins, sub-queries etc: https://github.com/Irrelon/ForerunnerDB – Rob Evans Dec 24 '15 at 10:39

4 Answers4

2

You can use jStorage in conjunction with jLinq

1

Have you try my open source library https://bitbucket.org/ytkyaw/ydn-db/wiki/Home. It supports IndexedDB, WebSQL and localStorage. Query is NoSQL style, i.e, index base key range query. Multiple index query require use of composite index or key joining algorithm. Currently there is basic query interface to SQL, which will be better over time.

Large-scale web app, most of them are CRM, use the library in production.

Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83
  • This looks pretty interesting! How does it handle the key range querying and SQL when it's using localStorage instead of IndexedDB? – user1424744 Apr 01 '13 at 22:31
  • localStorage key range query use on-memory AVL tree. it is implemented since 0.4.9 release. SQL for localStorage is not yet implemented. – Kyaw Tun Apr 03 '13 at 04:10
1

I have written two simple APIs to deal with Storage API. One of them is a wrapper to make it easy to work with both local and session storage: https://github.com/chambs/minidb/

Something like:

minidb.local.set('name', 'Willian');

minidb.local.get('name'); //gives you "Willian"

minidb.session.set('userData', {id:333, name: 'Joseph'});

minidb.session.get('userData'); //gives that object

The other one is a namespace based for the localStorage API only (no session). Basicly you can add "rows" grouped into namespaces, so that you can separate the data based on these namespaces: https://github.com/chambs/zonjs

Something like:

zon('user').insert({name: 'Willian', email: 'o.chambs@gmail.com'});

zon('user').del('8739874397494');

Where 'user' is the namespace you have defined. It is possible to have as many namespaces as you like for the same origin/domain

Hope it helps :)

0

I've used lawnchair for a small couple scale internal tools where I work and the experience has been very positive overall.

Something I learned in the process: Douglas Crockford's JSON-js cycle.js solved my stringify issues when doing save/get on double-linked objects.

Somebody posted an issue on the lawnchair github repo describing the same problem and saved me a lot of headaches. https://github.com/brianleroux/lawnchair/issues/105

Noah C
  • 208
  • 1
  • 5
  • 1
    The way it queries is that it reiterates over the hash table...it's not useful for DB > 10K rows – delphi Mar 26 '13 at 21:06
  • A good point, thanks for the feedback. Though the original question mentions sorting and aggregating user-selected date ranges. I can't think of a scenario where that kind of use case would bump into the 10K record threshold. – Noah C Mar 26 '13 at 23:13