14

I've got a bit of a problem, I'm about to start a 4-6 month project which will need offline support. AppCache is awesome and accepted as the standard but the big browsers are still undecided about the database implementation with Opera, Safari and Chrome opting for WebSQL (SQLite) and Mozilla and supposedly IE backing IndexedDB.

I know that Chrome will also develop an IndexedDB option in the future but I could not find any info about any release dates etc.

Now, in 4-6 months, lets call it November I want to have a system that supports most (does not have to be all) latest version browsers (assuming IE9 is out, FF4, and Chrome 6). I don't really want to have a IndexedDB/websql dual implementation. The thought of using localStorage as a big ugly blob database gives me the shivers and I would love not to use Gears.

What do you, my esteemed colleagues recommend I do, what path should I follow? Which pill to take?

Thanks All

Guido

Jake Neumann
  • 372
  • 4
  • 13
gatapia
  • 3,574
  • 4
  • 40
  • 48
  • A bit of an update, this project is now completed and I ended up building my own abstraction layer that goes like this: 1) IndexedDB 2) Web SQL 3) Gears DB (in fallback order). Its sim ilar to lawnchair but a bit more flexible. This was actually quite simple to do and works really well. If I had the scope I would have liked to have added Flash storage fallback option also. I did not support local storage as this had a 2.5MB limit (useless in my scenario) – gatapia Oct 08 '10 at 22:41
  • gatapia, have you published that abstraction layer for the community? – Peder Rice May 24 '11 at 19:52
  • 4
    @Peder Rice, yes I have actually: [here](https://github.com/PicNet/picnet_closure_repo/tree/master/src/pn/data) – gatapia Jun 02 '11 at 19:32

3 Answers3

3

i would indeed go for (a.o.) localstorage. I wrote a small proof of concept of such an offline web-app earlier this year (cfr. this blogpost and the offline-enabled webapp here), the basic approach being;

  • put data in arrays/ objects
  • use standard javascript functions to do CRUD (or go for jlinq)
  • json-ify the array/object for storage
  • use a storage-abstraction library like persistjs to store/ retrieve json-ified array/object
futtta
  • 5,917
  • 2
  • 21
  • 33
  • 1
    The thought of having to marshal to/from string/JSON every time a database update is required is really ugly. And may be ok for a very small databsae but this will fall over very quickly with a large dataset. I don't like this however, you may be right and this may be the most compatible approach and I'm sure a 'segmentation' approach could be taken to improve performance but sheesh why does FireFox have to make my life so hard!!!!! – gatapia Jul 01 '10 at 21:40
  • 1
    you're absolutely right, this is an ugly solution, but as far as i know there is no true alternative for now. some misc. bits: * it wasn't only mozilla that objected to webdb, ms didn't want to implement sqlite either * ms & mozilla, the original backers, will implement indexdb * opera expressed interest in indexdb as well, so they'll probably follow as well * the chromium-guys are working on indexdb (http://www.chromium.org/developers/design-documents/indexeddb) so it seems safe to assume it'll end up in chrome (and maybe safari, as a lot of work will be in webkit) – futtta Jul 02 '10 at 13:05
2

Another option that is relatively well proven is Adobe Air. http://www.adobe.com/products/air/

Example of apps using it here http://balsamiq.com/ and here http://www.tweetdeck.com/

No it's not standards based, but it does offer probably the best out of the box functionality for an application like you describe.

Joshua
  • 5,336
  • 1
  • 28
  • 42
0

I know this is a bit late, but for future projects you could try SequelSphere.

It is new to the market, but should hopefully cover this type of project. It is an HTML5 Relational Database Engine that supports SQL and stores it's data in Local Storage. It does not use WebSQL databases, but rather is its own SQL engine. As such, it will work in any JavaScript compliant browser (one of your chief concerns). However, it currently only supports Local Storage as a persistence mechanism, so the size may be an issue for you. I would expect SequelSphere to eventually tie in other local persistence engines such as gears and flash, but that's not immediately available.

For full disclosure: I am related to the company SequelSphere. :)

John Fowler
  • 3,173
  • 3
  • 18
  • 31