Created
January 27, 2011 13:44
-
-
Save michael/798515 to your computer and use it in GitHub Desktop.
A super-lightweight wrapper that treats CouchDB like a key/value store.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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