brick-storage-indexeddb

Demo

Check it live!

Usage

  1. Import Web Components polyfill:

     <script src="bower_components/platform/platform.js"></script>
    
  2. Import Custom Element:

     <link rel="import" href="src/brick-storage-indexeddb.html">
    
  3. Start using it:

     <brick-storage-indexeddb></brick-storage-indexeddb>
    

Options

Attribute Options Default Description
name string storage The database name.
keyname string id The name of the unique primary key to use for get, set and remove operations. Defaults to an auto-incrementing id.
indexname string One or multiple indices which can be used to order and the results of queries which return multiple items.

Methods

Method Returns a promise for Description
insert(object) key of the saved object Insert an object.
set(object) key of the saved object Insert/upate an object.
setMany(objects) - Insert/upate multiple objects.
get(key) object Retrieves the object with the key.
remove(key) undefined Deletes the object with the key.
getMany(options) array multiple objects Retrieves multiple stored objects. If no filtering options are provided, it returns all objects.
  • options.start - The first key of the results.
  • options.end - The last key of the results.
  • options.count - The number of results.
  • options.offset - The offset of the first result when set to true.
  • options.orderby - The key/index by which the results will be ordered. options.start and options.end use this key/index
  • options.reverse - Reverse the order of the results.
size() number of stored items Returns the number of stored objects.
clear() undefined Deletes all database entries.

Development

In order to run it locally you'll need to fetch some dependencies and a basic server setup.

License

MIT License