0.0.4 • Published 11 years ago

brainy-sync v0.0.4

Weekly downloads
15
License
-
Repository
-
Last release
11 years ago

brainy-sync

a database ambiguous Backbone.sync replacement for Node.js. this allows you to use model instance functions like fetch and save on the server.

installation

$ npm install brainy-sync

usage

true to Backbone.sync, you can override the global sync handler as well as indivudal model sync methods. it is totally transparent- the Backbone API remains identical.

global override

var Sync = require('brainy-sync'),
  Backbone = require('backbone'),
  config = { host: 'http://127.0.0.1', port: 5984, name: 'brainy' };

Backbone.sync = Sync('couchdb, config');

instance override

var User = Backbone.Model.extend({
  url: '/users',
  sync: Sync('couchdb', config)
});

var user = new User({
  username: 'catshirt'
});

user.save({
  success: function() {
    console.log('saved');
  }
});