# SyncGateway.DatabaseApi

All URIs are relative to *http://localhost:4984/*

Method | HTTP request | Description
------------- | ------------- | -------------
[**dbAllDocsGet**](DatabaseApi.md#dbAllDocsGet) | **GET** /{db}/_all_docs | All docs
[**dbAllDocsPost**](DatabaseApi.md#dbAllDocsPost) | **POST** /{db}/_all_docs | All docs
[**dbBulkDocsPost**](DatabaseApi.md#dbBulkDocsPost) | **POST** /{db}/_bulk_docs | Bulk docs
[**dbBulkGetPost**](DatabaseApi.md#dbBulkGetPost) | **POST** /{db}/_bulk_get | Bulk get
[**dbChangesGet**](DatabaseApi.md#dbChangesGet) | **GET** /{db}/_changes | Changes
[**dbChangesPost**](DatabaseApi.md#dbChangesPost) | **POST** /{db}/_changes | Changes
[**dbGet**](DatabaseApi.md#dbGet) | **GET** /{db}/ | Database info


<a name="dbAllDocsGet"></a>
# **dbAllDocsGet**
> QueryResult dbAllDocsGet(db, opts)

All docs

This request returns a built-in view of all the documents in the database. 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.DatabaseApi();

var db = "db_example"; // String | Database name

var opts = { 
  'access': false, // Boolean | Indicates whether to include in the response a list of what access this document grants (i.e. which users it allows to access which channels.) This option may only be used from the admin port.
  'channels': false, // Boolean | Indicates whether to include in the response a channels property containing an array of channels this document is assigned to. (Channels not accessible by the user making the request will not be listed.)
  'includeDocs': false, // Boolean | Default is false. Indicates whether to include the associated document with each result. If there are conflicts, only the winning revision is returned.
  'revs': false, // Boolean | Default is false. Indicates whether to include a _revisions property for each document in the response, which contains a revision history of the document.
  'updateSeq': false, // Boolean | Default is false. Indicates whether to include the update_seq (document sequence ID) property in the response.
  'limit': 56, // Number | Limits the number of result rows to the specified value. Using a value of 0 has the same effect as the value 1.
  'keys': ["keys_example"], // [String] | Specify a list of document IDs.
  'startkey': "startkey_example", // String | Returns records starting with the specified key.
  'endkey': "endkey_example" // String | If this parameter is provided, stop returning records when the specified key is reached.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.dbAllDocsGet(db, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **access** | **Boolean**| Indicates whether to include in the response a list of what access this document grants (i.e. which users it allows to access which channels.) This option may only be used from the admin port. | [optional] [default to false]
 **channels** | **Boolean**| Indicates whether to include in the response a channels property containing an array of channels this document is assigned to. (Channels not accessible by the user making the request will not be listed.) | [optional] [default to false]
 **includeDocs** | **Boolean**| Default is false. Indicates whether to include the associated document with each result. If there are conflicts, only the winning revision is returned. | [optional] [default to false]
 **revs** | **Boolean**| Default is false. Indicates whether to include a _revisions property for each document in the response, which contains a revision history of the document. | [optional] [default to false]
 **updateSeq** | **Boolean**| Default is false. Indicates whether to include the update_seq (document sequence ID) property in the response. | [optional] [default to false]
 **limit** | **Number**| Limits the number of result rows to the specified value. Using a value of 0 has the same effect as the value 1. | [optional] 
 **keys** | [**[String]**](String.md)| Specify a list of document IDs. | [optional] 
 **startkey** | **String**| Returns records starting with the specified key. | [optional] 
 **endkey** | **String**| If this parameter is provided, stop returning records when the specified key is reached. | [optional] 

### Return type

[**QueryResult**](QueryResult.md)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="dbAllDocsPost"></a>
# **dbAllDocsPost**
> QueryResult dbAllDocsPost(db, opts)

All docs

This request retrieves specified documents from the database. 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.DatabaseApi();

var db = "db_example"; // String | Database name

var opts = { 
  'access': false, // Boolean | Indicates whether to include in the response a list of what access this document grants (i.e. which users it allows to access which channels.) This option may only be used from the admin port.
  'channels': false, // Boolean | Indicates whether to include in the response a channels property containing an array of channels this document is assigned to. (Channels not accessible by the user making the request will not be listed.)
  'includeDocs': false, // Boolean | Default is false. Indicates whether to include the associated document with each result. If there are conflicts, only the winning revision is returned.
  'revs': false, // Boolean | Default is false. Indicates whether to include a _revisions property for each document in the response, which contains a revision history of the document.
  'updateSeq': false, // Boolean | Default is false. Indicates whether to include the update_seq (document sequence ID) property in the response.
  'body': new SyncGateway.AllDocs() // AllDocs | Request body
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.dbAllDocsPost(db, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **access** | **Boolean**| Indicates whether to include in the response a list of what access this document grants (i.e. which users it allows to access which channels.) This option may only be used from the admin port. | [optional] [default to false]
 **channels** | **Boolean**| Indicates whether to include in the response a channels property containing an array of channels this document is assigned to. (Channels not accessible by the user making the request will not be listed.) | [optional] [default to false]
 **includeDocs** | **Boolean**| Default is false. Indicates whether to include the associated document with each result. If there are conflicts, only the winning revision is returned. | [optional] [default to false]
 **revs** | **Boolean**| Default is false. Indicates whether to include a _revisions property for each document in the response, which contains a revision history of the document. | [optional] [default to false]
 **updateSeq** | **Boolean**| Default is false. Indicates whether to include the update_seq (document sequence ID) property in the response. | [optional] [default to false]
 **body** | [**AllDocs**](AllDocs.md)| Request body | [optional] 

### Return type

[**QueryResult**](QueryResult.md)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="dbBulkDocsPost"></a>
# **dbBulkDocsPost**
> [Success] dbBulkDocsPost(db, opts)

Bulk docs

This request enables you to add, update, or delete multiple documents to a database in a single request. To add new documents, you can either specify the ID (&#x60;_id&#x60;) or let the software create an ID. To update existing documents, you must provide the document ID, revision identifier (&#x60;_rev&#x60;), and new document values. To delete existing documents you must provide the document ID, revision identifier, and the deletion flag (&#x60;_deleted&#x60;).  The JSON returned by the &#x60;_bulk_docs&#x60; operation consists of an array of JSON structures, one for each document in the original submission. The returned JSON structure should be examined to ensure that all of the documents submitted in the original request were successfully added to the database. 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.DatabaseApi();

var db = "db_example"; // String | Database name

var opts = { 
  'bulkDocsBody': new SyncGateway.BulkDocsBody() // BulkDocsBody | The request body
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.dbBulkDocsPost(db, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **bulkDocsBody** | [**BulkDocsBody**](BulkDocsBody.md)| The request body | [optional] 

### Return type

[**[Success]**](Success.md)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="dbBulkGetPost"></a>
# **dbBulkGetPost**
> InlineResponse200 dbBulkGetPost(db, opts)

Bulk get

This request returns any number of documents, as individual bodies in a MIME multipart response. Each enclosed body contains one requested document. The bodies appear in the same order as in the request, but can also be identified by their X-Doc-ID and X-Rev-ID headers. A body for a document with no attachments will have content type application/json and contain the document itself. A body for a document that has attachments will be written as a nested multipart/related body. Its first part will be the document&#39;s JSON, and the subsequent parts will be the attachments (each identified by a Content-Disposition header giving its attachment name.) 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.DatabaseApi();

var db = "db_example"; // String | Database name

var opts = { 
  'revs': false, // Boolean | Default is false. Indicates whether to include a _revisions property for each document in the response, which contains a revision history of the document.
  'attachments': false, // Boolean | Default is false. Include attachment bodies in response.
  'bulkGetBody': new SyncGateway.BulkGetBody() // BulkGetBody | List of documents being requested. Each array element is an object that must contain an id property giving the document ID. It may contain a rev property if a specific revision is desired. It may contain an atts_since property (as in a single-document GET) to limit which attachments are sent.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.dbBulkGetPost(db, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **revs** | **Boolean**| Default is false. Indicates whether to include a _revisions property for each document in the response, which contains a revision history of the document. | [optional] [default to false]
 **attachments** | **Boolean**| Default is false. Include attachment bodies in response. | [optional] [default to false]
 **bulkGetBody** | [**BulkGetBody**](BulkGetBody.md)| List of documents being requested. Each array element is an object that must contain an id property giving the document ID. It may contain a rev property if a specific revision is desired. It may contain an atts_since property (as in a single-document GET) to limit which attachments are sent. | [optional] 

### Return type

[**InlineResponse200**](InlineResponse200.md)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="dbChangesGet"></a>
# **dbChangesGet**
> Changes dbChangesGet(db, opts)

Changes

This request retrieves a sorted list of changes made to documents in the database, in time order of application. Each document appears at most once, ordered by its most recent change, regardless of how many times it&#39;s been changed. This request can be used to listen for update and modifications to the database for post processing or synchronization. A continuously connected changes feed is a reasonable approach for generating a real-time log for most applications. 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.DatabaseApi();

var db = "db_example"; // String | Database name

var opts = { 
  'limit': 56, // Number | Limits the number of result rows to the specified value. Using a value of 0 has the same effect as the value 1.
  'style': "main_only", // String | Default is 'main_only'. Number of revisions to return in the changes array. main_only returns the current winning revision, all_docs returns all leaf revisions including conflicts and deleted former conflicts.
  'activeOnly': false, // Boolean | Default is false. When true, the changes response doesn't include either deleted documents, or notification for documents that the user no longer has access to.
  'includeDocs': false, // Boolean | Default is false. Indicates whether to include the associated document with each result. If there are conflicts, only the winning revision is returned.
  'filter': "filter_example", // String | Indicates that the reported documents should be filtered. The valid values are sync_gateway/bychannel and _doc_ids.
  'channels': "channels_example", // String | A comma-separated list of channel names. The response will be filtered to only documents in these channels. (This parameter must be used with the sync_gateway/bychannel filter parameter; see below.)
  'docIds': ["docIds_example"], // [String] | A list of document IDs as a valid JSON array. The response will be filtered to only documents with these IDs. (This parameter must be used with the _doc_ids filter parameter; see below.)
  'feed': "normal", // String | Default is 'normal'. Specifies type of change feed. Valid values are normal, continuous, longpoll, websocket.
  'since': 56, // Number | Starts the results from the change immediately after the given sequence ID. Sequence IDs should be considered opaque; they come from the last_seq property of a prior response.
  'heartbeat': 0, // Number | Default is 0. Interval in milliseconds at which an empty line (CRLF) is written to the response. This helps prevent gateways from deciding the socket is idle and closing it. Only applicable to longpoll or continuous feeds. Overrides any timeout to keep the feed alive indefinitely. Setting to 0 results in no heartbeat.
  'timeout': 300000 // Number | Default is 300000. Maximum period in milliseconds to wait for a change before the response is sent, even if there are no results. Only applicable for longpoll or continuous feeds. Setting to 0 results in no timeout.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.dbChangesGet(db, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **limit** | **Number**| Limits the number of result rows to the specified value. Using a value of 0 has the same effect as the value 1. | [optional] 
 **style** | **String**| Default is &#39;main_only&#39;. Number of revisions to return in the changes array. main_only returns the current winning revision, all_docs returns all leaf revisions including conflicts and deleted former conflicts. | [optional] [default to main_only]
 **activeOnly** | **Boolean**| Default is false. When true, the changes response doesn&#39;t include either deleted documents, or notification for documents that the user no longer has access to. | [optional] [default to false]
 **includeDocs** | **Boolean**| Default is false. Indicates whether to include the associated document with each result. If there are conflicts, only the winning revision is returned. | [optional] [default to false]
 **filter** | **String**| Indicates that the reported documents should be filtered. The valid values are sync_gateway/bychannel and _doc_ids. | [optional] 
 **channels** | **String**| A comma-separated list of channel names. The response will be filtered to only documents in these channels. (This parameter must be used with the sync_gateway/bychannel filter parameter; see below.) | [optional] 
 **docIds** | [**[String]**](String.md)| A list of document IDs as a valid JSON array. The response will be filtered to only documents with these IDs. (This parameter must be used with the _doc_ids filter parameter; see below.) | [optional] 
 **feed** | **String**| Default is &#39;normal&#39;. Specifies type of change feed. Valid values are normal, continuous, longpoll, websocket. | [optional] [default to normal]
 **since** | **Number**| Starts the results from the change immediately after the given sequence ID. Sequence IDs should be considered opaque; they come from the last_seq property of a prior response. | [optional] 
 **heartbeat** | **Number**| Default is 0. Interval in milliseconds at which an empty line (CRLF) is written to the response. This helps prevent gateways from deciding the socket is idle and closing it. Only applicable to longpoll or continuous feeds. Overrides any timeout to keep the feed alive indefinitely. Setting to 0 results in no heartbeat. | [optional] [default to 0]
 **timeout** | **Number**| Default is 300000. Maximum period in milliseconds to wait for a change before the response is sent, even if there are no results. Only applicable for longpoll or continuous feeds. Setting to 0 results in no timeout. | [optional] [default to 300000]

### Return type

[**Changes**](Changes.md)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="dbChangesPost"></a>
# **dbChangesPost**
> Changes dbChangesPost(db, opts)

Changes

Same as the GET /_changes request except the parameters are in the JSON body. 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.DatabaseApi();

var db = "db_example"; // String | Database name

var opts = { 
  'changesBody': new SyncGateway.ChangesBody() // ChangesBody | The request body
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.dbChangesPost(db, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **changesBody** | [**ChangesBody**](ChangesBody.md)| The request body | [optional] 

### Return type

[**Changes**](Changes.md)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="dbGet"></a>
# **dbGet**
> Database dbGet(db)

Database info

This request retrieves information about the database. 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.DatabaseApi();

var db = "db_example"; // String | Database name


var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.dbGet(db, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 

### Return type

[**Database**](Database.md)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

