A wheelhouse library to use couchdb as a database while useing backbone on ther server.

npm install wheelhouse-couch
1 downloads in the last day
70 downloads in the last week
94 downloads in the last month



A wheelhouse package for using Backbone server side with flatiron. This sets Couch as the data store for the server and is largely a rewrite of backbone-couch. CouchDB communication is via the excellent cradle CouchDB library.


var flatiron = require('flatiron')
  , app = flatiron.app
  , dbPlugin = require('wheelhouse-couch')

app.use(flatiron.plugins.http, {})
app.use(dbPlugin, {
  name: 'database-name'
  , host: 'localhost' // default
  , port: 5984 // default
  // also takes cradle options
  , cache: false // disabled by default b/c cradle's cache doesn't play nicely if your app is hosted on multiple servers
  , raw: false // cradle default
  // additional advanced options
  , getId: function(model){ // used internally to get the DB id from the model. the default behavior follows: {{collectionName}}/{{UUID}}
    return model.url().substring(1) // default
  , getCollectionName: function(collection){
    // you might want to override this if your collection urls don't match your collection names
    // e.g. if your collection url is '/api/collectionName', you could use: `return collection.url.split('/')[2]`
    return collection.url.substring(1) // default
}, function(){} // do something after the database connection has been established

After using the plugin, Backbone.sync is overridden to use CouchDB on the server.

app.config.set('db:name', 'database-name')
app.config.set('db:host', 'localhost')
app.config.set('db:cache', true)
// …

Important note:

Your models should override the default id attribute to use _id.

var model = Backbone.Model.extend({
  idAttribute: '_id'


The grunt way

You must have grunt-cli installed: sudo npm i -g grunt-cli npm test

You'll need to have a user on your db with the username test and the password test.

The Mocha way

mocha test/specs -ui bdd



security fix it is no longer possible to bypass the delete method by manually setting isDeleted: true


Updated publish process.


Send updatedAt and createdAt back out when they're modified.


Publish error


  • breaking change (kinda) no longer automatically reading options from app.config.get('db') (this never really was operational anyway)
  • update the backbone/collection view to only look at ids with a / in them… for performance.
  • Add unit tests
  • Updates retry on a document update conflict
  • fix error callbacks. They now return just the response … which is as Backbone intended.
  • many methods were private before. They're now exposed in .internals
  • changes feed now removes attributes from the model that were deleted in the db
  • the delete method is now much smarter… by just re-implementing the update method
  • new createdAt and updatedAt are now automatically created and updated.


  • on db update error, don't log the input. It leads to log pollution.


  • pass notOriginal for changes feed upates. This enables ignoring of events on changes that are triggered on another server.

formerly known as flatiron-couch-backbone

npm loves you