Created
January 24, 2012 23:59
-
-
Save lxbarth/1673660 to your computer and use it in GitHub Desktop.
Example of backbone-couch integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var couch = require('backbone-couch'); | |
var register = models.Company.register; | |
models.Company.register = function(server) { | |
var config = server.plugin.config; | |
var options = { | |
host: config.couchHost, | |
port: config.couchPort, | |
name: config.couchPrefix + '_companies' | |
}; | |
// Give the model access to the CouchDB object. | |
var db = couch(options); | |
this.prototype.couchDb = db.db; | |
this.prototype.sync = db.sync; | |
return register.apply(this, arguments); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment