Skip to content

Everyplay/backbone-db-indexing-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Interface for Backbone-db compatible adapters that can store indices

Resources

License

Stars

Watchers

Forks

Packages

No packages published