$.couch
$.couch is used to communicate with a CouchDB server, the server methods can
be called directly without creating an instance. Typically all methods are
passed an
options
object which defines a success callback which
is called with the data returned from the http request to CouchDB, you can
find the other settings that can be used in the options
object
from
jQuery.ajax settings
$.couch.activeTasks({
success: function (data) {
console.log(data);
}
});
Outputs (for example):
[
{
"pid" : "<0.11599.0>",
"status" : "Copied 0 of 18369 changes (0%)",
"task" : "recipes",
"type" : "Database Compaction"
}
]
Methods
$.couch.activeTasks(options)
You can obtain a list of active tasks by using the /_active_tasks URL.
The result is a JSON array of the currently running tasks, with each task
being described with a single object.
Parameters:
{ajaxSettings} | options | jQuery ajax settings |
$.couch.allDbs(options)
Returns a list of all the databases in the CouchDB instance
Parameters:
{ajaxSettings} | options | jQuery ajax settings |
$.couch.config(options, section, option, value)
View and edit the CouchDB configuration, called with just the options
parameter the entire config is returned, you can be more specific by
passing the section and option parameters, if you specify a value that
value will be stored in the configuration.
Parameters:
{ajaxSettings} | options | jQuery ajax settings | |
{String} | section | Optional | the section of the config |
{String} | option | Optional | the particular config option |
{String} | value | Optional | value to be set |
$.couch.info(options)
Accessing the root of a CouchDB instance returns meta information about
the instance. The response is a JSON structure containing information
about the server, including a welcome message and the version of the
server.
Parameters:
{ajaxSettings} | options | jQuery ajax settings |
$.couch.login(options)
Authenticate against CouchDB, the
options
parameter is
expected to have name
and password
fields.
Parameters:
{ajaxSettings} | options | jQuery ajax settings |
$.couch.logout(options)
Delete your current CouchDB user session
Parameters:
{ajaxSettings} | options | jQuery ajax settings |
$.couch.newUUID(cacheNum)
Fetch a new UUID
Parameters:
{Int} | cacheNum | Number of uuids to keep cached for future use |
$.couch.replicate(source, target, ajaxOptions, repOpts)
Request, configure, or stop, a replication operation.
Parameters:
{String} | source | Path or url to source database | |
{String} | target | Path or url to target database | |
{ajaxSettings} | ajaxOptions | jQuery ajax settings | |
{Object} | repOpts | Additional replication options |
$.couch.session(options)
Returns the session information for the currently logged in user.
Parameters:
{ajaxSettings} | options | jQuery ajax settings |
$.couch.signup(user_doc, password, options)
Create a new user on the CouchDB server,
user_doc
is an
object with a name
field and other information you want
to store relating to that user, for example
{"name": "daleharvey"}
Parameters:
{Object} | user_doc | Users details | |
{String} | password | Users password | |
{ajaxSettings} | options | jQuery ajax settings |