backbone-db-indexing-adapter

0.1.1 • Public • Published

backbone-db-indexing-adapter

Build Status

Interface for Backbone-db compatible adapters that can store indices.

IndexedDBAdapterInterface

Interface that compliant backbone-db adapter must implement. Interface defines the following methods:

addToIndex

Adds a key to index.

readFromIndex

Read keys from the index.

readFromIndexes

Read keys from multiple indexes.

removeFromIndex

Remove models' keys from index.

removeIndex

Removes the index completely.

existsInIndex

Check if key exists in the index.

indexCount

Get number of keys in the index.

score

Return the score of key in the index.

IndexingDBLocal

Backbone-db adapter that implements IndexedDBAdapterInterface, storing indexes in memory/localStorage

Usage:

  var IndexingDBLocal = require('backbone-db-indexing-adapter').IndexingDBLocal;
  var store = new IndexingDBLocal('test');

IndexedCollectionMixin

Mixin for Collections that use IndexedDBAdapterInterface compliant backbone-db adapter

Usage:

  var TestIndexedCollection = MyCollection.extend(
    _.extend({}, IndexedCollectionMixin, {
      indexDb: store
    })
  );
  var c = new TestIndexedCollection();
  return c.readFromIndex().then(...);

Tests

npm run test

Package Sidebar

Install

npm i backbone-db-indexing-adapter

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • mikkolehtinen