brainy-sync

mongodb sync adapter for Backbone resources

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.

$ npm install brainy-sync

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.

var Sync = require('brainy-sync'),
  Backbone = require('backbone'),
  config = { host: 'http://127.0.0.1', port: 5984, name: 'brainy' };
 
Backbone.sync = Sync('couchdb, config');
var User = Backbone.Model.extend({
  url: '/users',
  sync: Sync('couchdb', config)
});
 
var user = new User({
  username: 'catshirt'
});
 
user.save({
  success: function() {
    console.log('saved');
  }
});