couchdb-utils
v0.1.0
Published
CouchDB utils
Downloads
7
Readme
couchdb-utils
Management of versioning and updates of couchdb design documents is based on grave project.
var cradle = require('cradle'),
cutils = require('couchdb-utils');
var db = new (cradle.Connection)().database('my-database');
var design = new cutils.Design(db, 'my-view', '0.0.2');
design.view('all', {
map : function (doc) {
if (doc.type === 'my-doc') emit(doc._id, 1);
},
});
design.end(function(err) {
console.log('all views are up-to-date');
});
Design views, lists and updates
db.design(name, version)
Start a design with a name
and a version
.
Theversion
should be understood by
semver.
design.view(name, view)
Define a couchdb view. CouchDB views have map
, reduce
, and fields of that
sort.
design.list(name, list)
Define a couchdb list. CouchDB lists are functions that look like
function (head, req) { /* ... */ }
.
design.update(name, update)
Define a couchdb update. These look like function (doc, req) { /* ... */ }
.
design.end(callback)
Declare the end of the design document definitions and save them to couchdb when the design version is greater than the couchdb version.