couchdb-seed-design

Seed CouchDB's design documents with nano

couchdb-seed-design

Seed CouchDB design documents with nano.

npm install couchdb-seed-design
var nano = require('nano');
var seed = require('couchdb-seed-design');
var db = nano('http://localhost:5984/design');
 
seed(db, {
  person: {
    views: {
      byFirstNamefunction (doc) {
        emit(doc.firstName);
      },
      byLastNamefunction (doc) {
        emit(doc.lastName);
      },
      byFullNamefunction (doc) {
        emit(doc.firstName + ' ' + doc.lastName);
      }
    }
  }
}, function () {
  console.dir(arguments);
});
  • db (object, required) - nano (or compatible) database object
  • design (object, required) - design object
  • cb (function, optional) - callback

Creates a set of CouchDB design documents basing on design object. Each key in design object becomes a separate design document called ('_design/' + key).

If no changes between remote design documents and design object are detected, no updates are sent to CouchDB.