Webanizr Logo
Open / sluit menu
Module authentication

Last change: January 6, 2020

Current version: 1.0.1

The myIndexedDB sets, gets and deletes items from and to the IndexedDB storage in modern browsers.

The initial version (1.0.1) of the myIndexedDB brings the functionality of indexedDB back into a simple and easy key-value based storage. 

  • The concept of databases in IndexedDB: the database to use, in myIndexedDB it will be set to the name__container parameter.
  • The concept of ObjectStores in IndexedDB: the table to work in, in myIndexedDB it will be set to the name of the name__container parameter (too).
  • The reason to have the database and objectstore name the same, is because databases and objectstores are created on the fly using the IndexedDB built in upgrade process. Using multiple objectstores within the same version would require creating new versions (since only upgrades can modify the database structure). For the initial version which is just a key value storage system, this is not necessary yet and omitted. 
  • The concept of versioning: the module itself takes care of version control, the initial version sticks to the default database structure which is hardcoded in this module, on which versions are only used for creating the initial database. 
  • The default database structure is initially minimal: just a key(field=dataname) and a value(field=value).

The module of myIndexedDB's initial version is very similar in its interface to the existing myLocalStorage module. Some differences between the initial version of myIndexedDB module and the myLocalStorage module are:

  • delete and clear actions will not return the erased data in their callback.
  • name__container is required for all calls to the module, since this is the way how IndexedDB creates data. 

There are significant differences between localstorage and IndexedDB storage types, the latter is much more powerful. This is the primary reason for splitting them up. This module will be improved further with more functionality that might not be possible to implement in localstorage. 

webanizr.collect('myIndexedDB', parameters, callack);

webanizr.send('myIndexedDB', data, parameters, callack);

collect

parameters

The myIndexedDB module accepts the following parameters:

name__container (required for all actions)

The name of the database and objectstore to get data from, delete data from, list all variables from or to clear.

type__action (optional)

The type of action to perform. The following types are supported:

  • get: get data from the local storage. It returns the value, or null if it is not available.
  • delete: delete data from the local storage
  • list: show all variables in a container in local storage
  • clear: clear all data from either the local storage or a container in the local storage

If no type is specified the type get is assumed.

name__var (required for the get and delete actions)

The variable to get or delete.

callback

The function to send the data to.

send

data

The myIndexedDB module accepts a javascript object with a key-value mapping. Each consecutive key and corresponding value is stored.

parameters

The myIndexedDB module accepts the following parameters:

name__container

The name of the database + objectstore to store the data in.

callback

The callback to call after the data is stored.

Changelog

  • January 6, 2020: 1.0.0 - first version of the module
  • January 8, 2020: 1.0.1 - collect get returns data without wrapping it first in a dict