Class: Database

Database

The Database class creates a convenience object for accessing
database-specific functionality of a CouchDB Host for a given database.

new Database(name, conn)

Creates a Database object for a CouchDB instance, using a given Connection.

Name Type Description
name String
  • The name of the database to be accessed.
conn Connection
  • The Connection to the database's host.

Members

The Connection to the database's host.

nameString

The name of the database to be accessed

Methods

copy(path, parms){Promise}

Convenience method to send a COPY request to a CouchDB database.

Name Type Description
path String

the path to the desired object below the database-URL

parms Object

Object containing key/vale pairs of parametrers to
be appended to the URL must be JSON encodable

Returns:
Promise object. If the promise resolves a
CouchResult is returned, if it rejects a CouchError is
returned. See the offical CouchDB documentation for what you can expect
from a COPY call under different situations.

delete(path, parms){Promise}

Convenience method to send a DELETE request to a CouchDB database.

Name Type Description
path String

the path to the desired object below the database-URL

parms Object

Object containing key/vale pairs of parametrers to
be appended to the URL must be JSON encodable

Returns:
Promise object. If the promise resolves a
CouchResult is returned, if it rejects a CouchError is
returned.

get(path, parms){Promise}

Convenience method to send a GET request to a CouchDB database.

Name Type Description
path String

the path to the desired object below the database-URL

parms Object

Object containing key/vale pairs of parametrers to
be appended to the URL must be JSON encodable

Returns:
Promise object. If the promise resolves a
CouchResult is returned, if it rejects a CouchError is
returned.

Convenience method to send a HEAD request to a CouchDB database.

Name Type Description
path String

the path to the desired object below the database-URL

parms Object

Object containing key/vale pairs of parametrers to
be appended to the URL must be JSON encodable

Returns:
Promise object. If the promise resolves a
CouchResult is returned, if it rejects a CouchError is
returned. The CouchResult will not have a body and but you can
inspect the request header within.

make_request(method, path, opts){Promise}

The central workhorse for performing the HTTP requests.

Name Type Description
method String

The HTTP verb to be used in the request

path String

The relative path for the request

opts Object

An Object containing optional parameters for the request:

Name Type Description
headers Object

Object containing key/value pairs of custom
HTTP Headers

parms Object

Object containing key/value pairs of parameters to
be appended to the URL must be JSON encodable

body Object

Object or Array to be JSON encoded and put into
the request body

Returns:
Promise object. If the promise resolves a
CouchResult is returned, if it rejects a CouchError is
returned.

post(path, body, parms){Promise}

Convenience method to send a POST request to a CouchDB database.

Name Type Description
path String

the path to the desired object below the database-URL

body Object

Object or Array to be JSON encoded and put into
the request body

parms Object

Object containing key/vale pairs of parametrers to
be appended to the URL must be JSON encodable

Returns:
Promise object. If the promise resolves a
CouchResult is returned, if it rejects a CouchError is
returned.

put(path, body, parms){Promise}

Convenience method to send a PUT request to a CouchDB database.

Name Type Description
path String

the path to the desired object below the database-URL

body Object

Object or Array to be JSON encoded and put into
the request body

parms Object

Object containing key/vale pairs of parametrers to
be appended to the URL must be JSON encodable

Returns:
Promise object. If the promise resolves a
CouchResult is returned, if it rejects a CouchError is
returned.