Queryable client-side storage [closed]
Asked Answered
F

4

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

Fenestra answered 18/2, 2013 at 22:27 Comment(4)
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.Joselyn
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)Fenestra
why the hell is this question closed as not constructive? It's super helpfulNoisette
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: github.com/Irrelon/ForerunnerDBSkewer
O
2

You can use jStorage in conjunction with jLinq

Oistrakh answered 1/4, 2013 at 19:17 Comment(0)
S
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.

Spirometer answered 27/3, 2013 at 2:45 Comment(2)
This looks pretty interesting! How does it handle the key range querying and SQL when it's using localStorage instead of IndexedDB?Fenestra
localStorage key range query use on-memory AVL tree. it is implemented since 0.4.9 release. SQL for localStorage is not yet implemented.Spirometer
I
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: '[email protected]'});

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 :)

Inveigle answered 1/4, 2013 at 14:56 Comment(0)
D
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

Devereux answered 19/2, 2013 at 7:50 Comment(2)
The way it queries is that it reiterates over the hash table...it's not useful for DB > 10K rowsIsooctane
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.Devereux

© 2022 - 2024 — McMap. All rights reserved.