new DB(client, name, authopt)
Methods for CouchDB database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
client |
Client | Clerk client. |
|
name |
String | DB name. |
|
auth |
String |
<optional> |
Authentication header value. |
Returns:
This object for chaining.
Methods
all(queryopt, headersopt, callbackopt) → {Promise}
Query all documents by ID.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query |
Object |
<optional> |
HTTP query options. Properties
|
|||||||||||||||||||||||||||||||||||||||||||||
headers |
Object |
<optional> |
HTTP headers. |
|||||||||||||||||||||||||||||||||||||||||||||
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
attach(docopt, attachmentName, data, queryopt, headersopt, callbackopt) → {Promise}
Upload attachment to document.
Set the Content-Type
header.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
doc |
Object |
<optional> |
Document. Requires |
attachmentName |
String | Attachment name. |
|
data |
Object | Data. |
|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
attachment(docOrId, attachmentName, queryopt, headersopt, callbackopt) → {Promise}
Download attachment from document.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
docOrId |
Object | String | Document or document ID. |
|
attachmentName |
String | Attachment name. |
|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
changes(queryopt, headersopt, callbackopt) → {Promise}
Get database changes.
The feed
option determines how the callback is called:
normal
calls the callback once.longpoll
waits for a response, then calls the callback once.continuous
calls the callback each time an update is received. Implemented as thedatabase#follow()
method.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query |
Object |
<optional> |
HTTP query options. Properties
|
||||||||||||||||||||||||||||||||||||||||
headers |
Object |
<optional> |
HTTP headers. |
||||||||||||||||||||||||||||||||||||||||
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
commit(queryopt, headersopt, callbackopt) → {Promise}
Ensure recent changes are committed to disk.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
compact(designopt, queryopt, headersopt, callbackopt) → {Promise}
Compact database or design.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
design |
String |
<optional> |
Design name if compacting design indexes. |
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
copy(source, target, queryopt, headersopt, callbackopt) → {Promise}
Copy document.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
source |
Object | Source document. Properties
|
|||||||||||||||||||||
target |
Object | Target document. Properties
|
|||||||||||||||||||||
query |
Object |
<optional> |
HTTP query options. |
||||||||||||||||||||
headers |
Object |
<optional> |
HTTP headers. |
||||||||||||||||||||
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
create(queryopt, headersopt, callbackopt) → {Promise}
Create database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
del(docs, queryopt, headersopt, callbackopt) → {Promise}
Delete document(s).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
docs |
Object | Array.<Object> | Document or array of documents. |
|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
destroy(queryopt, headersopt, callbackopt) → {Promise}
Destroy database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
exists(queryopt, headersopt, callbackopt) → {Promise}
Check if database exists.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
find(view, queryopt, headersopt, callbackopt) → {Promise}
Query a view.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
view |
String | Object | View name (e.g. mydesign/myview) or temporary view definition. Using a temporary view is strongly not recommended for production use. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
query |
Object |
<optional> |
HTTP query options. Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
headers |
Object |
<optional> |
HTTP headers. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
follow()
Follow database changes.
get(id, queryopt, headersopt, callbackopt) → {Promise}
Fetch document.
Set rev
in query
.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
String | Document ID. |
|||||||||||||
query |
Object |
<optional> |
HTTP query options. Properties
|
||||||||||||
headers |
Object |
<optional> |
HTTP headers. |
||||||||||||
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
head(id, queryopt, headersopt, callbackopt) → {Promise}
Get document metadata.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
String | Document ID. |
|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
info(queryopt, headersopt, callbackopt) → {Promise}
Get database info.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
post(doc, queryopt, headersopt, callbackopt) → {Promise}
Post document(s) to database.
If documents have no ID, a document ID will be automatically generated on the server. Attachments are not currently supported.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
doc |
Object | Array.<Object> | Document or array of documents. Properties
|
|||||||||||||||||||||||||||||
query |
Object |
<optional> |
HTTP query options. Properties
|
||||||||||||||||||||||||||||
headers |
Object |
<optional> |
HTTP headers. |
||||||||||||||||||||||||||||
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
purge(revs, queryopt, headersopt, callbackopt) → {Promise}
Purge deleted documents from database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
revs |
Object | Map of document IDs to revisions to be purged. |
|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
put(doc, optionsopt, queryopt, headersopt, callbackopt) → {Promise}
Put document in database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
doc |
Object | Document data. Requires |
|
options |
String |
<optional> |
Options. |
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
replicate(options, queryopt, headersopt, callbackopt) → {Promise}
Replicate database.
This convenience function sets options.source
and options.target
to
the selected database name. Either options.source
or options.target
must be overridden for a successful replication request.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Options | Options. Accepts all options from
Properties
|
||||||||||||||||
query |
Object |
<optional> |
HTTP query options. |
|||||||||||||||
headers |
Object |
<optional> |
HTTP headers. |
|||||||||||||||
callback |
handler |
<optional> |
Callback function. |
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
update(handler, idopt, queryopt, dataopt, headersopt, callbackopt) → {Promise}
Update document using server-side handler.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
handler |
String | Update handler. Example: mydesign/myhandler |
|
id |
String |
<optional> |
Document ID. |
query |
Object |
<optional> |
HTTP query options. |
data |
Object | String |
<optional> |
Data. |
headers |
Object |
<optional> |
Headers. |
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise
vacuum(queryopt, headersopt, callbackopt) → {Promise}
Remove unused views.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
HTTP query options. |
headers |
Object |
<optional> |
HTTP headers. |
callback |
handler |
<optional> |
Callback function. |
- Source:
- See:
Returns:
A Promise, if no callback is provided,
otherwise null
.
- Type
- Promise