# SyncGateway.DocumentApi

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

Method | HTTP request | Description
------------- | ------------- | -------------
[**dbDocDelete**](DocumentApi.md#dbDocDelete) | **DELETE** /{db}/{doc} | Delete document
[**dbDocGet**](DocumentApi.md#dbDocGet) | **GET** /{db}/{doc} | Get document
[**dbDocPut**](DocumentApi.md#dbDocPut) | **PUT** /{db}/{doc} | Create or update document
[**dbLocalLocalDocDelete**](DocumentApi.md#dbLocalLocalDocDelete) | **DELETE** /{db}/_local/{local_doc} | Delete a local document
[**dbLocalLocalDocGet**](DocumentApi.md#dbLocalLocalDocGet) | **GET** /{db}/_local/{local_doc} | Get local doc
[**dbLocalLocalDocPut**](DocumentApi.md#dbLocalLocalDocPut) | **PUT** /{db}/_local/{local_doc} | Create or update a local document
[**post**](DocumentApi.md#post) | **POST** /{db}/ | Create document


<a name="dbDocDelete"></a>
# **dbDocDelete**
> Success dbDocDelete(dbdoc, opts)

Delete document

This request deletes a document from the database. When a document is deleted, the revision number is updated so the database can track the deletion in synchronized copies. 

### 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.DocumentApi();

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

var doc = "doc_example"; // String | Document ID

var opts = { 
  'rev': "rev_example" // String | Revision identifier of the parent revision the new one should replace. (Not used when creating a new document.)
};

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

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **doc** | **String**| Document ID | 
 **rev** | **String**| Revision identifier of the parent revision the new one should replace. (Not used when creating a new document.) | [optional] 

### Return type

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

### Authorization

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

### HTTP request headers

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

<a name="dbDocGet"></a>
# **dbDocGet**
> Object dbDocGet(dbdoc, opts)

Get document

This request retrieves a document from a 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.DocumentApi();

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

var doc = "doc_example"; // String | Document ID

var opts = { 
  'attachments': false, // Boolean | Default is false. Include attachment bodies in response.
  'attsSince': ["attsSince_example"], // [String] | Include attachments only since specified revisions. Does not include attachments for specified revisions.
  'openRevs': ["openRevs_example"], // [String] | Option to fetch specified revisions of the document. The value can be `all` to fetch all leaf revisions or an array of revision numbers (i.e. open_revs=[\"rev1\", \"rev2\"]). If this option is specified the response will be in multipart format. Use the `Accept: application/json` request header to get the result as a JSON object.
  '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.
  'showExp': false // Boolean | Whether to show the _exp property in the response.
};

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

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **doc** | **String**| Document ID | 
 **attachments** | **Boolean**| Default is false. Include attachment bodies in response. | [optional] [default to false]
 **attsSince** | [**[String]**](String.md)| Include attachments only since specified revisions. Does not include attachments for specified revisions. | [optional] 
 **openRevs** | [**[String]**](String.md)| Option to fetch specified revisions of the document. The value can be &#x60;all&#x60; to fetch all leaf revisions or an array of revision numbers (i.e. open_revs&#x3D;[\&quot;rev1\&quot;, \&quot;rev2\&quot;]). If this option is specified the response will be in multipart format. Use the &#x60;Accept: application/json&#x60; request header to get the result as a JSON object. | [optional] 
 **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]
 **showExp** | **Boolean**| Whether to show the _exp property in the response. | [optional] [default to false]

### Return type

**Object**

### Authorization

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

### HTTP request headers

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

<a name="dbDocPut"></a>
# **dbDocPut**
> Success dbDocPut(dbdoc, opts)

Create or update document

This request creates a new document or creates a new revision of an existing document. It enables you to specify the identifier for a new document rather than letting the software create an identifier. If you want to create a new document and let the software create an identifier, use the POST /db request. If the document specified by doc does not exist, a new document is created and assigned the identifier specified in doc. If the document already exists, the document is updated with the JSON document in the message body and given a new revision. 

### 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.DocumentApi();

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

var doc = "doc_example"; // String | Document ID

var opts = { 
  'document': new SyncGateway.Document(), // Document | Request body
  'newEdits': true, // Boolean | Default is true. Setting this to false indicates that the request body is an already-existing revision that should be directly inserted into the database, instead of a modification to apply to the current document. (This mode is used by the replicato.)
  'rev': "rev_example" // String | Revision identifier of the parent revision the new one should replace. (Not used when creating a new document.)
};

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

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **doc** | **String**| Document ID | 
 **document** | [**Document**](Document.md)| Request body | [optional] 
 **newEdits** | **Boolean**| Default is true. Setting this to false indicates that the request body is an already-existing revision that should be directly inserted into the database, instead of a modification to apply to the current document. (This mode is used by the replicato.) | [optional] [default to true]
 **rev** | **String**| Revision identifier of the parent revision the new one should replace. (Not used when creating a new document.) | [optional] 

### Return type

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

### Authorization

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

### HTTP request headers

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

<a name="dbLocalLocalDocDelete"></a>
# **dbLocalLocalDocDelete**
> Success dbLocalLocalDocDelete(dblocalDoc, opts)

Delete a local document

This request deletes a local document. Local document IDs begin with _local/. Local documents are not replicated or indexed, don&#39;t support attachments, and don&#39;t save revision histories. In practice they are almost only used by Couchbase Lite&#39;s replicator, as a place to store replication checkpoint data. 

### 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.DocumentApi();

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

var localDoc = "localDoc_example"; // String | Local document IDs begin with _local/.

var opts = { 
  'rev': "rev_example" // String | Revision identifier of the parent revision the new one should replace. (Not used when creating a new document.)
  'batch': "batch_example" // String | Stores the document in batch mode. To use, set the value to ok.
};

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

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **localDoc** | **String**| Local document IDs begin with _local/. | 
 **rev** | **String**| Revision identifier of the parent revision the new one should replace. (Not used when creating a new document.) | [optional] 
 **batch** | **String**| Stores the document in batch mode. To use, set the value to ok. | [optional] 

### Return type

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

### Authorization

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

### HTTP request headers

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

<a name="dbLocalLocalDocGet"></a>
# **dbLocalLocalDocGet**
> Success dbLocalLocalDocGet(dblocalDoc)

Get local doc

This request retrieves a local document. Local document IDs begin with _local/. Local documents are not replicated or indexed, don&#39;t support attachments, and don&#39;t save revision histories. In practice they are almost only used by Couchbase Lite&#39;s replicator, as a place to store replication checkpoint data. 

### 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.DocumentApi();

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

var localDoc = "localDoc_example"; // String | Local document IDs begin with _local/.


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

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **localDoc** | **String**| Local document IDs begin with _local/. | 

### Return type

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

### Authorization

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

### HTTP request headers

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

<a name="dbLocalLocalDocPut"></a>
# **dbLocalLocalDocPut**
> Success dbLocalLocalDocPut(dblocalDoc)

Create or update a local document

This request creates or updates a local document. Local document IDs begin with _local/. Local documents are not replicated or indexed, don&#39;t support attachments, and don&#39;t save revision histories. In practice they are almost only used by the client&#39;s replicator, as a place to store replication checkpoint data. 

### 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.DocumentApi();

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

var localDoc = "localDoc_example"; // String | Local document IDs begin with _local/.


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

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **localDoc** | **String**| Local document IDs begin with _local/. | 

### Return type

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

### Authorization

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

### HTTP request headers

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

<a name="post"></a>
# **post**
> Success post(db, opts)

Create document

This request creates a new document in the specified database. You can either specify the document ID by including the _id in the request message body (the value must be a string), or let the software generate an ID. 

### 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.DocumentApi();

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

var opts = { 
  'body': null // Object | The document body
};

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

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **body** | **Object**| The document body | [optional] 

### Return type

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

### Authorization

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

### HTTP request headers

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

