Skip to content
LocalStorage wrapper providing dojo/store interface
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This store provides a dojo/store interface when working with LocalStorage. Check out the Dojo Object Store Tutorial or the Creating Dojo Stores Tutorial


LocalStorage only works with key/value pairs where value is a string. Dojo-local-storage in contrast works with objects. A JSON serialization of an object is stored in LocalStorage, storing strings directly is not supported.


require(["dojo-local-storage/LocalStorage"], function (LocalStorage) {
    var store = new LocalStorage({
        idProperty: 'id'

    // storing an object
    var id = store.add({
        title: 'Elementarteilchen',
        year: 2006,
        id: 'abc'

    // querying the store
    var result = store.query({
        year: 2006
        sort: [{ attribute:"year", descending: false }]

    // updating an object
    var id = store.put({
        id: 'abc',
        title: 'Elementarteilchen',
        year: 2006

    // getting an object
    var object = store.get('abc');

    // deleting an object

Working With A Data Subset By Configuration

Sometimes it can be desirable to configure a store such that it only operates on a subset of data. This feature can be helpful to use LocalStorage as a read/writeable replacement for a remote API during development. Transparently to a client, Dojo-local-storage adds a property to each object it stores and removes it upon retrieval. Name and value of this property can be passed to the constructor upon instantiation

var store = new LocalStorage({
    subsetProperty: 'mySubsetProperty',
    subsetName: "movies"

Running Tests

  1. cd <path-to-dojo-local-storage>
  2. npm install
  3. Point browser to http://<localhost>/dojo-local-storage/node_modules/intern/client.html?config=tests/intern


Original Gist by dmachi

You can’t perform that action at this time.