CommonJS CouchDB Client for use in browser, node.js, and narwhal
Latest commit 5a68f1a Dec 28, 2014 @nrstott Merge pull request #6 from jdc0589/master
fixed hardcoded uuids count
Failed to load latest commit information.
lib fixed hardcoded _uuids count (ignores user specified count) Jan 21, 2012
tests fixed bug in getDoc Dec 14, 2011
.gitignore added gitignore. Jan 21, 2012
.npmignore added npmignore Dec 13, 2011 added Sep 20, 2011
package.json v0.3.7 Dec 21, 2011

CouchDB Client

CouchDB-CommonJS is a promise-based CouchDB client. It can be used in the browser or on the server via Node.js.

Example Usage in Node.js

Create a module named hello-couch.js and add the following code:

var couchdb = require('couchdb');
var client  = couchdb.createClient(5984, 'localhost');
var db      = client.db('helloCouch');

var doc = { _id: 'helloCouch', text: 'Hello CouchDB!' };

db.saveDoc(doc).then(function() {
    console.log('document saved!');

    db.openDoc('helloCouch').then(function(doc) {
        console.log('retrieved document!');

Before executing this module, create a database in your CouchDB named helloCouch using futon.

This program creates a document in the CouchDB Database helloCouch. Next, it saves a document to the database with a key of helloCouch and a text property. Then, it retrieves the document from the database and prints the contents of the document to the console.


Methods on CouchClient and Database return promises. The promises are Promises/A compliant. You may be familiar with promises in jQuery as they have recently been added to make Ajax calls cleaner.