new Database(name, conn)
Creates a Database object for a CouchDB instance, using a given Connection.
Name | Type | Description |
---|---|---|
name |
String |
|
conn |
Connection |
|
Members
-
connConnection
-
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 encodableReturns:
Promise
object. If the promise resolves aCouchResult
is returned, if it rejects aCouchError
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 encodableReturns:
Promise
object. If the promise resolves aCouchResult
is returned, if it rejects aCouchError
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 encodableReturns:
Promise
object. If the promise resolves aCouchResult
is returned, if it rejects aCouchError
is
returned.
-
head(path, parms){Promise}
-
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 encodableReturns:
Promise
object. If the promise resolves aCouchResult
is returned, if it rejects aCouchError
is
returned. TheCouchResult
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 Headersparms
Object Object containing key/value pairs of parameters to
be appended to the URL must be JSON encodablebody
Object Object or Array to be JSON encoded and put into
the request bodyReturns:
Promise
object. If the promise resolves aCouchResult
is returned, if it rejects aCouchError
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 bodyparms
Object Object containing key/vale pairs of parametrers to
be appended to the URL must be JSON encodableReturns:
Promise
object. If the promise resolves aCouchResult
is returned, if it rejects aCouchError
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 bodyparms
Object Object containing key/vale pairs of parametrers to
be appended to the URL must be JSON encodableReturns:
Promise
object. If the promise resolves aCouchResult
is returned, if it rejects aCouchError
is
returned.