This plugin is now wheelhouse-couch
https://npmjs.org/package/wheelhouse-couch https://github.com/joeybaker/wheelhouse-couch
A flatiron plugin that allows you to use Backbone server side, and uses Couch for it's data store. This is largely a rewrite of backbone-couch to get it to play nicely with flatiron and use the excellent cradle CouchDB library.
var flatiron = require('flatiron')
, app = flatiron.app
, dbPlugin = require('flatiron-couch-backbone')
app.use(flatiron.plugins.http, {})
app.use(dbPlugin, {
name: 'database-name'
, host: 'localhost' // default
, port: 5984 // default
// also takes cradle options
, cache: true // disabled by default in development
, raw: false // cradle default
, callback: function(){} // do something after the database connection has been established
, getId: function(model){ // used to get the DB id from the model. the default behavior follows: {{collectionName}}/{{UUID}}
return model.url().substring(1) // default
}
, getCollectionName: function(collection){
return collection.url.substring(1) // default
}
})
app.start(8999)
After using the plugin, Backbone.sync
is overridden to use CouchDB.
Your models should override the default id
attribute to use _id
.
var model = Backbone.Model.extend({
idAttribute: '_id'
})
You must have grunt-cli installed: sudo npm i -g grunt-cli
npm test