This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

backsync

0.1.13 • Public • Published

backsync

A minimalistic library for integrating Backbone models with different data stores. Mongodb, Couchdb and Memory already included.

Installation

$ npm install backsync

Usage

var backsync = require( "backsync" );
 
var Todo = Backbone.Model.extend({
    urlRoot: "mongodb://127.0.0.1:27017/test/todos",
    sync: backsync.mongodb(); // alternatively, use backsync.memory()
})

You can also override the general Backbone.sync method in order to affect all of the Models in the application, instead of the specific Models and Collections.

Then, you can create, update, delete and read all of the model instances normally following Backbone's documentation. The same applies for Collections, and run queries with the .fetch() command:

var TodoCollection = Backbone.Model.extend({
    url: "mongodb://127.0.0.1:27017/test/todos",
    sync: backsync.mongodb(); // alternatively, use backsync.memory()
});
 
new TodoCollection()
    .on( "sync", function() {
        console.log( this.models );
    }).fetch({
        data: {
            user: "123",
            $sort: "order",
            $skip: 10,
            $limit: 10
        }
    });
 

Building your own backend

In order to create your own data stores for Backbone, implement the following methods: create (alias: insert), update, read, delete (alias: remove) and search (alias: list). Each of these functions receive the model, options object and a callback to call with the updated resource attributes.

See the implementation of the memory or mongo sync methods to learn more.

Package Sidebar

Install

npm i backsync

Weekly Downloads

1

Version

0.1.13

License

MIT

Last publish

Collaborators

  • avinoamr