Skip to content

Instantly share code, notes, and snippets.

@michael
Created January 27, 2011 13:44
Show Gist options
  • Select an option

  • Save michael/798515 to your computer and use it in GitHub Desktop.

Select an option

Save michael/798515 to your computer and use it in GitHub Desktop.
A super-lightweight wrapper that treats CouchDB like a key/value store.
var BareCouch = require('bare-couch');
var db = BareCouch("http://username:password@yourhost:5984/users");
// Get A document (@rev is optional)
db.get('frank@37-c0b8d2436', function(err, doc) {
// The doc, unless there wasn't an error
});
// Set A document
db.set({"_id": "frank", "name": "Frank", "email": "[email protected]", _rev: "37-c0b8d2436"}, function(err, doc) {
// The updated doc containing the new revision, unless there wasn't an error
});
// If there's a conflict you can resolve it by choosing one of the conflicting revisions.
db.resolve({"_id": "frank", "_rev": "39-c0b8d2436"}, function(err, doc) {
// Either the resolved doc, or an error.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment