CouchDBClient
Table of Contents
Example
welcome.js
var CouchDBClient = require('couchdb-client');
var client = CouchDBClient({
host: '127.0.0.1',
port: '5984'
});
client.welcome(function (err, data) {
console.log(err || data);
});
If all goes to plan we have a welcome message.
Usage
After requiring it, you will get a constructor. Call the constructor with options to get a client.
Documentation
This will be moved to another site eventually.
CouchDBClient([options])
This constructs your client. The options object can have:
host: the host to connect to. Default: 127.0.0.1
port: the port to connect to. Default: 5984
var CouchDBClient = require('couchdb-client');
var client = CouchDBClient({
host: example.com,
port: 3000
});
#welcome(callback)
Fetches the welcome message from the couchdb server.
client.welcome(function (err, data) {
if (err) {
console.error(err);
} else {
console.log(data);
}
});
#createDB(name, callback)
Creates a database in the couchdb server. Will give an error if the database already exists.
client.createDB('foo', function (err, data) {
if(err) {
console.error(err);
} else {
console.log('Success:', data);
}
});
#getDB(name, callback)
Get a database from the server.
client.getDB('foo', function (err, data) {
if (err) {
console.error(err);
} else {
console.log(data);
}
});