Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

passing database creds to the database

  • Loading branch information...
commit fa0490766520098c382bd539e48e04db1d40b89f 1 parent 265bca0
@shane-tomlinson shane-tomlinson authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/backends/couchdb.js
View
13 lib/backends/couchdb.js
@@ -4,7 +4,12 @@ var Backend = function Backend(message, config, callback) {
var self = this;
this.message = message;
- this.conn = new (cradle.Connection)(config.db_host, config.db_port);
+ this.conn = new (cradle.Connection)(config.db_host, config.db_port, {
+ auth: {
+ username: config.db_user,
+ password: config.db_pass
+ }
+ });
this.db = this.conn.database(config.db_name);
this._maybeCreateDB(function(err, created) {
@@ -16,7 +21,7 @@ var Backend = function Backend(message, config, callback) {
feed.on('error', function(err) {
console.error(err);
- // require clients to handle error?
+ // require clients to handle error?
// seems weird, since we're otherwise not an event emitter
//self.message('error', err);
});
@@ -37,14 +42,14 @@ Backend.prototype._maybeCreateDB = function(callback) {
// create the db if necessary
this.db.exists(function(err, exists) {
if (err) return callback(err);
-
+
if (! exists) {
self.db.create(function(err, created) {
// data design document puts timestamp in key
// so you can do startkey/endkey queries
self.db.save('_design/data', {
-
+
// query all by timestamp
all: {
map: function(doc) {
Please sign in to comment.
Something went wrong with that request. Please try again.