CouchDBClient
Table of Contents
- Example
- Usage
- Documentation
- CouchDBClient
- #welcome
- #createDB
- #getDB
- #deleteDB
- #addDoc
- #getDoc
- #deleteDoc
- #addView
- #deleteView
- #useView
Example
welcome.js
var CouchDBClient = ;var client = host: '127.0.0.1' //The host to connect to port: '5984' //The port;client;
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 = ;var client = host: examplecom port: 3000;
#welcome(callback)
Fetches the welcome message from the couchdb server.
client;
#getUUIDs(num, callback)
Gets UUIDs from the server.
var id;client;
#createDB(name, callback)
Creates a database in the couchdb server. Will give an error if the database already exists.
client;
#getDB(name, callback)
Get a database from the server.
var rev;client;
#deleteDB(name, callback)
Deletes a database.
client;
#addDoc(name, id, [rev], callback)
Adds a doc, could also be used to update a doc.
var rev2;client;
#getDoc(name, id, callback)
Gets a document from the database.
client;
#deleteDoc(name, id, rev, callback)
Deletes a document.
client;
#addView(name, id, obj, callback)
Adds or updates a view.
client;
#deleteView(name, id, rev, callback)
Deletes a view.
client;
#useView(name, id, view, [key,] callback)
Uses a view with the specified key.
client;
Test
$ npm test
Lisence
MIT