Skip to content

Enduring Stash

Simple client-side persistence with a lightweight, promise-based API and multiple storage providers.

Created for The University of Auckland Department of Information Systems and Operations Management in 2013

Technologies: JavaScript, QUnit, Twitter Bootstrap

Requirements

As part of a mobile applications development project for The University of Auckland (still in progress), I needed to store data locally in a mobile application. The technology I initially used (WebSQL) is widely supported but has been abandoned as a standard, so I wanted to future proof by allowing the application to switch to something else depending on what was available on the device. None of the other frameworks available did exactly what I needed, since many required me to repeat my existing data definitions in their particular format, thus making my application less maintainable.

Solution

I blended ideas from a number of existing open source projects to come up with my own solution with the following features:

  • Written entirely in JavaScript, with the only dependency being either Q or jQuery (for promises)
  • Designed to work in a browser, including mobile browsers and application containers such as phonegap
  • Simple uniform API regardless of the actual data provider used
  • All requests return promises to provide uniformity when dealing with asynchronous requests
  • Automatically chooses the first available data provider
  • Data providers available are IndexedDB, WebSQL, WebStorage (local storage or session storage), cookies or memory

More Information

For more information, code examples, and a live demo, see either the Github repository, or the documentation site: http://sarahhenderson.github.io/enduring-stash/

Summary

I have released this component as Open Source in case it is useful for anyone else. We are continuing to use it without the mobile applications development project.