$.couch.db

$.couch.db is used to communicate with a specific CouchDB database
var $db = $.couch.db("mydatabase");
$db.allApps({
 success: function (data) {
   ... process data ...
 }
});

Methods

$.couch.db.allApps(options)
Fetch all the design docs with an index.html, options parameter expects an eachApp field which is a callback called on each app found.

Parameters:

{ajaxSettings} options jQuery ajax settings

$.couch.db.allDesignDocs(options)
Fetch all the design docs in this db

Parameters:

{ajaxSettings} options jQuery ajax settings

$.couch.db.allDocs(options)
Fetch all the docs in this db, you can specify an array of keys to fetch by passing the keys field in the options parameter.

Parameters:

{ajaxSettings} options jQuery ajax settings
docs for /db/all_docs/

$.couch.db.bulkRemove(docs, options)
Remove a set of documents

Parameters:

{String[]} docs List of document id's to remove
{ajaxSettings} options jQuery ajax settings
docs for /db/_bulk_docs

$.couch.db.bulkSave(docs, options)
Save a list of documents

Parameters:

{Object[]} docs List of documents to save
{ajaxSettings} options jQuery ajax settings
docs for /db/_bulk_docs

$.couch.db.compact(options)
Request compaction of the specified database.

Parameters:

{ajaxSettings} options jQuery ajax settings
docs for /db/_compact

$.couch.db.compactView(groupname, options)
Compacts the view indexes associated with the specified design document. You can use this in place of the full database compaction if you know a specific set of view indexes have been affected by a recent database change.

Parameters:

{String} groupname Name of design-doc to compact
{ajaxSettings} options jQuery ajax settings
docs for /db/_compact/design-doc

$.couch.db.copyDoc(docId, options, options)
The COPY command (which is non-standard HTTP) copies an existing document to a new or existing document.

Parameters:

{String[]} docId document id to copy
{ajaxSettings} options jQuery ajax settings
{ajaxSettings} options jQuery ajax settings
docs for COPY /db/doc

$.couch.db.create(options)
Create a new database

Parameters:

{ajaxSettings} options jQuery ajax settings
docs for PUT /db/

$.couch.db.drop(options)
Deletes the specified database, and all the documents and attachments contained within it.

Parameters:

{ajaxSettings} options jQuery ajax settings
docs for DELETE /db/

$.couch.db.getDbProperty(propName, options, ajaxOptions)
Fetch an arbitrary CouchDB database property

Parameters:

{String} propName Propery name to fetch
{ajaxSettings} options jQuery ajax settings
{ajaxSettings} ajaxOptions jQuery ajax settings
docs for /db/_prop

$.couch.db.info(options)
Gets information about the specified database.

Parameters:

{ajaxSettings} options jQuery ajax settings
docs for GET /db/

$.couch.db.list(list, view, options)
Fetch a _list view output, you can specify a list of keys in the options object to recieve only those keys.

Parameters:

{String} list Listname in the form of ddoc/listname
{String} view View to run list against
{ajaxSettings} options jQuery ajax settings
docs for /db/_design/design-doc/_list/l1/v1

$.couch.db.openDoc(docId, options, ajaxOptions)
Returns the specified doc from the specified db.

Parameters:

{String} docId id of document to fetch
{ajaxSettings} options jQuery ajax settings
{ajaxSettings} ajaxOptions jQuery ajax settings
docs for GET /db/doc

$.couch.db.query(mapFun, reduceFun, language, options)
Creates (and executes) a temporary view based on the view function supplied in the JSON request.

Parameters:

{Function} mapFun Map function
{Function} reduceFun Reduce function
{Function} language Language the map / reduce funs are implemented in
{ajaxSettings} options jQuery ajax settings
docs for /db/_temp_view

$.couch.db.removeDoc(doc, options)
Deletes the specified document from the database. You must supply the current (latest) revision and id of the document to delete eg removeDoc({_id:"mydoc", _rev: "1-2345"})

Parameters:

{Object} doc Document to delete
{ajaxSettings} options jQuery ajax settings
docs for DELETE /db/doc

$.couch.db.saveDoc(doc, options)
Create a new document in the specified database, using the supplied JSON document structure. If the JSON structure includes the _id field, then the document will be created with the specified document ID. If the _id field is not specified, a new unique ID will be generated.

Parameters:

{String} doc document to save
{ajaxSettings} options jQuery ajax settings
docs for GET /db/doc

$.couch.db.setDbProperty(propName, propValue, options, ajaxOptions)
Set an arbitrary CouchDB database property

Parameters:

{String} propName Propery name to fetch
{String} propValue Propery value to set
{ajaxSettings} options jQuery ajax settings
{ajaxSettings} ajaxOptions jQuery ajax settings
docs for /db/_prop

$.couch.db.view(name, options)
Executes the specified view-name from the specified design-doc design document, you can specify a list of keys in the options object to recieve only those keys.

Parameters:

{String} name View to run list against
{ajaxSettings} options jQuery ajax settings
docs for /db/ _design/design-doc/_list/l1/v1

$.couch.db.viewCleanup(options)
Cleans up the cached view output on disk for a given view.

Parameters:

{ajaxSettings} options jQuery ajax settings
docs for /db/_compact