README
Couch-Request
A really minimal CouchDB client module that adds just one level of abstraction on top of Request.
Install:
npm install couch-request
Configure:
Require the module:
var couchrequest = require('couch-request');
Configure the database:
var database = couchrequest( {databaseUrl: [DATABASE URL] } );
Example DATABASE URL if you want to use CouchDB running on localhost: http://127.0.0.1:5984/reqtest
Get data:
database( path, callback(err, results) );
database("_all_docs", function(err, results){
if( err ) {
// an error occurred
} else{
// do stuff with results
}
});
Post data:
database( path, object(s)ToStore, callback(err, results) );
database("", {name: "peter"}, function(err, data){
if( err ) {
// an error occurred
} else{
// do stuff with results
}
});
As you can see getting and posting stuff to and from the database is fairly simple.
The database function takes two or three arguments. If you provide two (the path and callback) couch-request will make a GET request for you. If you provide three (path, the object and callback), couch-request will make a POST request for you, posting the object passed in as the request body.
Copyright (c) 2013 Peter Koraca
Have fun,
Peter