0.1.13 • Published 10 years ago

backsync v0.1.13

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

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.

0.1.13

10 years ago

0.1.12

10 years ago

0.1.11

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.0.31

10 years ago

0.0.30

10 years ago

0.0.29

10 years ago

0.0.28

10 years ago

0.0.27

10 years ago

0.0.26

10 years ago

0.0.25

10 years ago

0.0.24

10 years ago

0.0.23

10 years ago

0.0.22

10 years ago

0.0.20

10 years ago

0.0.19

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.3

10 years ago