RemoteStorage.IndexedDB

IndexedDB Interface

TODO rewrite, doesn’t expose GPD anymore, it’s in cachinglayer now

This file exposes a get/put/delete interface, accessing data in an IndexedDB.

There are multiple parts to this interface

The RemoteStorage integration

  • RemoteStorage.IndexedDB._rs_supported() determines if IndexedDB support is available.  If it isn’t, RemoteStorage won’t initialize the feature.
  • RemoteStorage.IndexedDB._rs_init() initializes the feature.  It returns a promise that is fulfilled as soon as the database has been opened and migrated.

The storage interface (RemoteStorage.IndexedDB object)

  • Usually this is accessible via “remoteStorage.local”
  • #get() takes a path and returns a promise.
  • #put() takes a path, body and contentType and also returns a promise.
  • #delete() takes a path and also returns a promise.
  • #on(‘change’, ...) events, being fired whenever something changes in the storage.  Change events roughly follow the StorageEvent pattern.  They have “oldValue” and “newValue” properties, which can be used to distinguish create/update/delete operations and analyze changes in change handlers.  In addition they carry a “origin” property, which is either “window”, “local”, or “remote”.  “remote” events are fired whenever a change comes in from RemoteStorage.Sync.

The sync interface (also on RemoteStorage.IndexedDB object)

  • #getNodes([paths]) returns the requested nodes in a promise.
  • #setNodes(map) stores all the nodes given in the (path -> node) map.
Summary
RemoteStorage.IndexedDBIndexedDB Interface
Properties
changesQueuedGiven a node for which uncommitted changes exist, this cache stores either the entire uncommitted node, or false for a deletion.
changesRunningGiven a node for which uncommitted changes exist, this cache stores either the entire uncommitted node, or false for a deletion.

Properties

changesQueued

Given a node for which uncommitted changes exist, this cache stores either the entire uncommitted node, or false for a deletion.  The node’s path is used as the key.

changesQueued stores changes for which no IndexedDB transaction has been started yet.

changesRunning

Given a node for which uncommitted changes exist, this cache stores either the entire uncommitted node, or false for a deletion.  The node’s path is used as the key.

At any time there is at most one IndexedDB transaction running. changesRunning stores the changes that are included in that currently running IndexedDB transaction, or if none is running, of the last one that ran.

Close