backbone.lovefield
v0.1.10
Published
lovefield backend for backbone
Downloads
3
Readme
backbone.lovefield
lovefield backend for backbone.
This adapter is inspired by backbone.localStorage and backbone-indexeddb. I wanted to use more than localStorage, yet backbone-indexeddb wouldn't play well with backbone.validation.
import Backbone from 'backbone';
import lf from 'lovefield';
import {LoveStore} from 'backbone.lovefield';
// Create schema and make sure connection
// is available before defining models and collections.
// sb = lf.schema.create('dbname', 1);
// conn = undefined;
// sb.connect().then(function (db){conn=db;})
const TableStore = new LoveStore(conn, 'tablename');
const MyModel = Backbone.Model.extend({
loveStore: TableStore
});
const MyCollection = Backbone.Collection.extend({
loveStore: TableStore,
model: MyModel
});