mirror of https://gitee.com/bigwinds/arangodb
442 lines
43 KiB
JSON
442 lines
43 KiB
JSON
{
|
|
"basePath": "/",
|
|
"swaggerVersion": "1.1",
|
|
"apiVersion": "0.1",
|
|
"apis": [
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "is returned if the document was created successfully and <em>waitForSync</em> was <em>true</em>. <br><br>",
|
|
"code": "201"
|
|
},
|
|
{
|
|
"reason": "is returned if the document was created successfully and <em>waitForSync</em> was <em>false</em>. <br><br>",
|
|
"code": "202"
|
|
},
|
|
{
|
|
"reason": "is returned if the body does not contain a valid JSON representation of a document. The response body contains an error document in this case. <br><br>",
|
|
"code": "400"
|
|
},
|
|
{
|
|
"reason": "is returned if the collection specified by <em>collection</em> is unknown. The response body contains an error document in this case. <br><br>",
|
|
"code": "404"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "Json",
|
|
"paramType": "body",
|
|
"required": "true",
|
|
"name": "document",
|
|
"description": "A JSON representation of the document. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "true",
|
|
"name": "collection",
|
|
"description": "The collection name. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "Boolean",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "createCollection",
|
|
"description": "If this parameter has a value of <em>true</em> or <em>yes</em>, then the collection is created if it does not yet exist. Other values will be ignored so the collection must be present for the operation to succeed. <br><br> <em>Note</em>: this flag is not supported in a cluster. Using it will result in an error. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "Boolean",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "waitForSync",
|
|
"description": "Wait until document has been synced to disk. <br><br>"
|
|
}
|
|
],
|
|
"notes": "Creates a new document in the collection named <em>collection</em>. A JSON representation of the document must be passed as the body of the POST request. <br><br> If the document was created successfully, then the \"Location\" header contains the path to the newly created document. The \"ETag\" header field contains the revision of the document. <br><br> The body of the response contains a JSON object with the following attributes: <br><br> <ul class=\"swagger-list\"><li><em>_id</em> contains the document handle of the newly created document <li><em>_key</em> contains the document key <li><em>_rev</em> contains the document revision </ul> If the collection parameter <em>waitForSync</em> is <em>false</em>, then the call returns as soon as the document has been accepted. It will not wait until the document has been synced to disk. <br><br> Optionally, the URL parameter <em>waitForSync</em> can be used to force synchronisation of the document creation operation to disk even in case that the <em>waitForSync</em> flag had been disabled for the entire collection. Thus, the <em>waitForSync</em> URL parameter can be used to force synchronisation of just this specific operations. To use this, set the <em>waitForSync</em> parameter to <em>true</em>. If the <em>waitForSync</em> parameter is not specified or set to <em>false</em>, then the collection's default <em>waitForSync</em> behavior is applied. The <em>waitForSync</em> URL parameter cannot be used to disable synchronisation for collections that have a default <em>waitForSync</em> value of <em>true</em>. <br><br>",
|
|
"summary": "Create document",
|
|
"httpMethod": "POST",
|
|
"examples": "<br><br> Create a document given a collection named <em>products</em>. Note that the revision identifier might or might not by equal to the auto-generated key. <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\netag: \"1412108905\"\nlocation: /_db/_system/_api/document/products/1412108905\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1412108905\", \n \"_rev\" : \"1412108905\", \n \"_key\" : \"1412108905\" \n}\n</code></pre><br><br><br> Create a document in a collection named <em>products</em> with a collection-level <em>waitForSync</em> value of <em>false</em>. <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1412633193\"\nlocation: /_db/_system/_api/document/products/1412633193\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1412633193\", \n \"_rev\" : \"1412633193\", \n \"_key\" : \"1412633193\" \n}\n</code></pre><br><br><br> Create a document in a collection with a collection-level <em>waitForSync</em> value of <em>false</em>, but using the <em>waitForSync</em> URL parameter. <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products&waitForSync=true\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\netag: \"1413157481\"\nlocation: /_db/_system/_api/document/products/1413157481\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1413157481\", \n \"_rev\" : \"1413157481\", \n \"_key\" : \"1413157481\" \n}\n</code></pre><br><br><br> Create a document in a new, named collection <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products&createCollection=true\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1413681769\"\nlocation: /_db/_system/_api/document/products/1413681769\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1413681769\", \n \"_rev\" : \"1413681769\", \n \"_key\" : \"1413681769\" \n}\n</code></pre><br><br><br> Unknown collection name: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"collection 'products' not found\", \n \"code\" : 404, \n \"errorNum\" : 1203 \n}\n</code></pre><br><br><br> Illegal document: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products\n{ 1: \"World\" }\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"expecting attribute name\", \n \"code\" : 400, \n \"errorNum\" : 600 \n}\n</code></pre><br><br><br>",
|
|
"nickname": "CreateDocument"
|
|
}
|
|
],
|
|
"path": "/_api/document"
|
|
},
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "is returned if the document was found <br><br>",
|
|
"code": "200"
|
|
},
|
|
{
|
|
"reason": "is returned if the \"If-None-Match\" header is given and the document has the same version <br><br>",
|
|
"code": "304"
|
|
},
|
|
{
|
|
"reason": "is returned if the document or collection was not found <br><br>",
|
|
"code": "404"
|
|
},
|
|
{
|
|
"reason": "is returned if a \"If-Match\" header or <em>rev</em> is given and the found document has a different version. The response will also contain the found document's current revision in the <em>_rev</em> attribute. Additionally, the attributes <em>_id</em> and <em>_key</em> will be returned. <br><br>",
|
|
"code": "412"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "path",
|
|
"required": "true",
|
|
"name": "document-handle",
|
|
"description": "The handle of the document. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "header",
|
|
"name": "If-None-Match",
|
|
"description": "If the \"If-None-Match\" header is given, then it must contain exactly one etag. The document is returned, if it has a different revision than the given etag. Otherwise an <em>HTTP 304</em> is returned. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "header",
|
|
"name": "If-Match",
|
|
"description": "If the \"If-Match\" header is given, then it must contain exactly one etag. The document is returned, if it has the same revision ad the given etag. Otherwise a <em>HTTP 412</em> is returned. As an alternative you can supply the etag in an attribute <em>rev</em> in the URL. <br><br>"
|
|
}
|
|
],
|
|
"notes": "Returns the document identified by <em>document-handle</em>. The returned document contains two special attributes: <em>_id</em> containing the document handle and <em>_rev</em> containing the revision. <br><br>",
|
|
"summary": "Read document",
|
|
"httpMethod": "GET",
|
|
"examples": "<br><br> Use a document handle: <br><br><br><br><pre><code class=\"json\">shell> curl --data-binary @- --dump - http://localhost:8529/_api/document/products/1414206057\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1414206057\"\n\n{ \n \"hello\" : \"world\", \n \"_id\" : \"products/1414206057\", \n \"_rev\" : \"1414206057\", \n \"_key\" : \"1414206057\" \n}\n</code></pre><br><br><br> Use a document handle and an etag: <br><br><br><br><pre><code class=\"json\">shell> curl --header 'If-None-Match: \"1414795881\"' --dump - http://localhost:8529/_api/document/products/1414795881\n\n</code></pre><br><br><br> Unknown document handle: <br><br><br><br><pre><code class=\"json\">shell> curl --data-binary @- --dump - http://localhost:8529/_api/document/products/unknownhandle\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"document /_api/document/products/unknownhandle not found\", \n \"code\" : 404, \n \"errorNum\" : 1202 \n}\n</code></pre><br><br><br>",
|
|
"nickname": "ReadDocument"
|
|
}
|
|
],
|
|
"path": "/_api/document/{document-handle}"
|
|
},
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "All went good. <br><br>",
|
|
"code": "200"
|
|
},
|
|
{
|
|
"reason": "The collection does not exist. <br><br>",
|
|
"code": "404"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "true",
|
|
"name": "collection",
|
|
"description": "The name of the collection. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "type",
|
|
"description": "The type of the result. The following values are allowed: <br><br> <ul class=\"swagger-list\"><li><em>id</em>: returns a list of document ids (<em>_id</em> attributes) <li><em>key</em>: returns a list of document keys (<em>_key</em> attributes) <li><em>path</em>: returns a list of document URI paths. This is the default."
|
|
}
|
|
],
|
|
"notes": "Returns a list of all keys, ids, or URI paths for all documents in the collection identified by <em>collection</em>. The type of the result list is determined by the <em>type</em> attribute. <br><br> Note that the results have no defined order and thus the order should not be relied on. <br><br>",
|
|
"summary": "Read all documents",
|
|
"httpMethod": "GET",
|
|
"examples": "<br><br> Returns all document paths <br><br><br><br><pre><code class=\"json\">shell> curl --data-binary @- --dump - http://localhost:8529/_api/document/?collection=products\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"documents\" : [ \n \"/_api/document/products/1415778921\", \n \"/_api/document/products/1416106601\", \n \"/_api/document/products/1415451241\" \n ] \n}\n</code></pre><br><br><br> Returns all document keys <br><br><br><br><pre><code class=\"json\">shell> curl --data-binary @- --dump - http://localhost:8529/_api/document/?collection=products&type=key\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"documents\" : [ \n \"1417024105\", \n \"1416696425\", \n \"1417351785\" \n ] \n}\n</code></pre><br><br><br> Collection does not exist. <br><br><br><br><pre><code class=\"json\">shell> curl --data-binary @- --dump - http://localhost:8529/_api/document/?collection=doesnotexist\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"collection 'doesnotexist' not found\", \n \"code\" : 404, \n \"errorNum\" : 1203 \n}\n</code></pre><br><br><br>",
|
|
"nickname": "ReadAllDocuments"
|
|
}
|
|
],
|
|
"path": "/_api/document"
|
|
},
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "is returned if the document was found <br><br>",
|
|
"code": "200"
|
|
},
|
|
{
|
|
"reason": "is returned if the \"If-None-Match\" header is given and the document has same version <br><br>",
|
|
"code": "304"
|
|
},
|
|
{
|
|
"reason": "is returned if the document or collection was not found <br><br>",
|
|
"code": "404"
|
|
},
|
|
{
|
|
"reason": "is returned if a \"If-Match\" header or <em>rev</em> is given and the found document has a different version. The response will also contain the found document's current revision in the <em>etag</em> header. <br><br>",
|
|
"code": "412"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "path",
|
|
"required": "true",
|
|
"name": "document-handle",
|
|
"description": "The handle of the document. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "rev",
|
|
"description": "You can conditionally fetch a document based on a target revision id by using the <em>rev</em> URL parameter. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "header",
|
|
"name": "If-None-Match",
|
|
"description": "If the \"If-None-Match\" header is given, then it must contain exactly one etag. If the current document revision is different to the specified etag, an <em>HTTP 200</em> response is returned. If the current document revision is identical to the specified etag, then an <em>HTTP 304</em> is returned. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "header",
|
|
"name": "If-Match",
|
|
"description": "You can conditionally fetch a document based on a target revision id by using the <em>if-match</em> HTTP header. <br><br>"
|
|
}
|
|
],
|
|
"notes": "Like <em>GET</em>, but only returns the header fields and not the body. You can use this call to get the current revision of a document or check if the document was deleted. <br><br>",
|
|
"summary": "Read document header",
|
|
"httpMethod": "HEAD",
|
|
"examples": "<br><br><br><br><pre><code class=\"json\">shell> curl -X HEAD --data-binary @- --dump - http://localhost:8529/_api/document/products/1418138217\n\n</code></pre><br><br><br> <br><br>",
|
|
"nickname": "ReadDocumentHeader"
|
|
}
|
|
],
|
|
"path": "/_api/document/{document-handle}"
|
|
},
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "is returned if the document was replaced successfully and <em>waitForSync</em> was <em>true</em>. <br><br>",
|
|
"code": "201"
|
|
},
|
|
{
|
|
"reason": "is returned if the document was replaced successfully and <em>waitForSync</em> was <em>false</em>. <br><br>",
|
|
"code": "202"
|
|
},
|
|
{
|
|
"reason": "is returned if the body does not contain a valid JSON representation of a document. The response body contains an error document in this case. <br><br>",
|
|
"code": "400"
|
|
},
|
|
{
|
|
"reason": "is returned if the collection or the document was not found <br><br>",
|
|
"code": "404"
|
|
},
|
|
{
|
|
"reason": "is returned if a \"If-Match\" header or <em>rev</em> is given and the found document has a different version. The response will also contain the found document's current revision in the <em>_rev</em> attribute. Additionally, the attributes <em>_id</em> and <em>_key</em> will be returned. <br><br>",
|
|
"code": "412"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "Json",
|
|
"paramType": "body",
|
|
"required": "true",
|
|
"name": "document",
|
|
"description": "A JSON representation of the new document. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "path",
|
|
"required": "true",
|
|
"name": "document-handle",
|
|
"description": "The handle of the document. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "Boolean",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "waitForSync",
|
|
"description": "Wait until document has been synced to disk. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "rev",
|
|
"description": "You can conditionally replace a document based on a target revision id by using the <em>rev</em> URL parameter. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "policy",
|
|
"description": "To control the update behavior in case there is a revision mismatch, you can use the <em>policy</em> parameter (see below). <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "header",
|
|
"name": "If-Match",
|
|
"description": "You can conditionally replace a document based on a target revision id by using the <em>if-match</em> HTTP header. <br><br>"
|
|
}
|
|
],
|
|
"notes": "Completely updates (i.e. replaces) the document identified by <em>document-handle</em>. If the document exists and can be updated, then a <em>HTTP 201</em> is returned and the \"ETag\" header field contains the new revision of the document. <br><br> If the new document passed in the body of the request contains the <em>document-handle</em> in the attribute <em>_id</em> and the revision in <em>_rev</em>, these attributes will be ignored. Only the URI and the \"ETag\" header are relevant in order to avoid confusion when using proxies. <br><br> Optionally, the URL parameter <em>waitForSync</em> can be used to force synchronisation of the document replacement operation to disk even in case that the <em>waitForSync</em> flag had been disabled for the entire collection. Thus, the <em>waitForSync</em> URL parameter can be used to force synchronisation of just specific operations. To use this, set the <em>waitForSync</em> parameter to <em>true</em>. If the <em>waitForSync</em> parameter is not specified or set to <em>false</em>, then the collection's default <em>waitForSync</em> behavior is applied. The <em>waitForSync</em> URL parameter cannot be used to disable synchronisation for collections that have a default <em>waitForSync</em> value of <em>true</em>. <br><br> The body of the response contains a JSON object with the information about the handle and the revision. The attribute <em>_id</em> contains the known <em>document-handle</em> of the updated document, the attribute <em>_rev</em> contains the new document revision. <br><br> If the document does not exist, then a <em>HTTP 404</em> is returned and the body of the response contains an error document. <br><br> There are two ways for specifying the targeted document revision id for conditional replacements (i.e. replacements that will only be executed if the revision id found in the database matches the document revision id specified in the request): <ul class=\"swagger-list\"><li>specifying the target revision in the <em>rev</em> URL query parameter <li>specifying the target revision in the <em>if-match</em> HTTP header </ul> Specifying a target revision is optional, however, if done, only one of the described mechanisms must be used (either the <em>rev</em> URL parameter or the <em>if-match</em> HTTP header). Regardless which mechanism is used, the parameter needs to contain the target document revision id as returned in the <em>_rev</em> attribute of a document or by an HTTP <em>etag</em> header. <br><br> For example, to conditionally replace a document based on a specific revision id, you can use the following request: <br><br> <em>PUT /_api/document/document-handle?rev=etag</em> <br><br> If a target revision id is provided in the request (e.g. via the <em>etag</em> value in the <em>rev</em> URL query parameter above), ArangoDB will check that the revision id of the document found in the database is equal to the target revision id provided in the request. If there is a mismatch between the revision id, then by default a <em>HTTP 412</em> conflict is returned and no replacement is performed. <br><br> The conditional update behavior can be overriden with the <em>policy</em> URL query parameter: <br><br> <em>PUT /_api/document/document-handle?policy=policy</em> <br><br> If <em>policy</em> is set to <em>error</em>, then the behavior is as before: replacements will fail if the revision id found in the database does not match the target revision id specified in the request. <br><br> If <em>policy</em> is set to <em>last</em>, then the replacement will succeed, even if the revision id found in the database does not match the target revision id specified in the request. You can use the <em>last</em> *policy* to force replacements. <br><br>",
|
|
"summary": "Replace document",
|
|
"httpMethod": "PUT",
|
|
"examples": "<br><br> Using document handle: <br><br><br><br><pre><code class=\"json\">shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/document/products/1418728041\n{\"Hello\": \"you\"}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1419055721\"\nlocation: /_db/_system/_api/document/products/1418728041\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1418728041\", \n \"_rev\" : \"1419055721\", \n \"_key\" : \"1418728041\" \n}\n</code></pre><br><br><br> Unknown document handle: <br><br><br><br><pre><code class=\"json\">shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/document/products/1419580009\n{}\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"document /_api/document/products/1419580009 not found\", \n \"code\" : 404, \n \"errorNum\" : 1202 \n}\n</code></pre><br><br><br> Produce a revision conflict: <br><br><br><br><pre><code class=\"json\">shell> curl -X PUT --header 'If-Match: \"1420825193\"' --data-binary @- --dump - http://localhost:8529/_api/document/products/1420497513\n{\"other\":\"content\"}\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\netag: \"1420497513\"\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/1420497513\", \n \"_rev\" : \"1420497513\", \n \"_key\" : \"1420497513\" \n}\n</code></pre><br><br><br> Last write wins: <br><br><br><br><pre><code class=\"json\">shell> curl -X PUT --header 'If-Match: \"1421939305\"' --data-binary @- --dump - http://localhost:8529/_api/document/products/1421611625?policy=last\n{}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1422201449\"\nlocation: /_db/_system/_api/document/products/1421611625\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1421611625\", \n \"_rev\" : \"1422201449\", \n \"_key\" : \"1421611625\" \n}\n</code></pre><br><br><br> Alternative to header field: <br><br><br><br><pre><code class=\"json\">shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/document/products/1422725737?rev=1423053417\n{\"other\":\"content\"}\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\netag: \"1422725737\"\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/1422725737\", \n \"_rev\" : \"1422725737\", \n \"_key\" : \"1422725737\" \n}\n</code></pre><br><br><br>",
|
|
"nickname": "ReplaceDocument"
|
|
}
|
|
],
|
|
"path": "/_api/document/{document-handle}"
|
|
},
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "is returned if the document was created successfully and <em>waitForSync</em> was <em>true</em>. <br><br>",
|
|
"code": "201"
|
|
},
|
|
{
|
|
"reason": "is returned if the document was created successfully and <em>waitForSync</em> was <em>false</em>. <br><br>",
|
|
"code": "202"
|
|
},
|
|
{
|
|
"reason": "is returned if the body does not contain a valid JSON representation of a document. The response body contains an error document in this case. <br><br>",
|
|
"code": "400"
|
|
},
|
|
{
|
|
"reason": "is returned if the collection or the document was not found <br><br>",
|
|
"code": "404"
|
|
},
|
|
{
|
|
"reason": "is returned if a \"If-Match\" header or <em>rev</em> is given and the found document has a different version. The response will also contain the found document's current revision in the <em>_rev</em> attribute. Additionally, the attributes <em>_id</em> and <em>_key</em> will be returned. <br><br>",
|
|
"code": "412"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "Json",
|
|
"paramType": "body",
|
|
"required": "true",
|
|
"name": "document",
|
|
"description": "A JSON representation of the document update. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "path",
|
|
"required": "true",
|
|
"name": "document-handle",
|
|
"description": "The handle of the document. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "Boolean",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "keepNull",
|
|
"description": "If the intention is to delete existing attributes with the patch command, the URL query parameter <em>keepNull</em> can be used with a value of <em>false</em>. This will modify the behavior of the patch command to remove any attributes from the existing document that are contained in the patch document with an attribute value of <em>null</em>. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "Boolean",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "waitForSync",
|
|
"description": "Wait until document has been synced to disk. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "rev",
|
|
"description": "You can conditionally patch a document based on a target revision id by using the <em>rev</em> URL parameter. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "policy",
|
|
"description": "To control the update behavior in case there is a revision mismatch, you can use the <em>policy</em> parameter. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "header",
|
|
"name": "If-Match",
|
|
"description": "You can conditionally patch a document based on a target revision id by using the <em>if-match</em> HTTP header. <br><br>"
|
|
}
|
|
],
|
|
"notes": "Partially updates the document identified by <em>document-handle</em>. The body of the request must contain a JSON document with the attributes to patch (the patch document). All attributes from the patch document will be added to the existing document if they do not yet exist, and overwritten in the existing document if they do exist there. <br><br> Setting an attribute value to <em>null</em> in the patch document will cause a value of <em>null</em> be saved for the attribute by default. <br><br> Optionally, the URL parameter <em>waitForSync</em> can be used to force synchronisation of the document update operation to disk even in case that the <em>waitForSync</em> flag had been disabled for the entire collection. Thus, the <em>waitForSync</em> URL parameter can be used to force synchronisation of just specific operations. To use this, set the <em>waitForSync</em> parameter to <em>true</em>. If the <em>waitForSync</em> parameter is not specified or set to <em>false</em>, then the collection's default <em>waitForSync</em> behavior is applied. The <em>waitForSync</em> URL parameter cannot be used to disable synchronisation for collections that have a default <em>waitForSync</em> value of <em>true</em>. <br><br> The body of the response contains a JSON object with the information about the handle and the revision. The attribute <em>_id</em> contains the known <em>document-handle</em> of the updated document, the attribute <em>_rev</em> contains the new document revision. <br><br> If the document does not exist, then a <em>HTTP 404</em> is returned and the body of the response contains an error document. <br><br> You can conditionally update a document based on a target revision id by using either the <em>rev</em> URL parameter or the <em>if-match</em> HTTP header. To control the update behavior in case there is a revision mismatch, you can use the <em>policy</em> parameter. This is the same as when replacing documents (see replacing documents for details). <br><br>",
|
|
"summary": " Patch document",
|
|
"httpMethod": "PATCH",
|
|
"examples": "<br><br> patches an existing document with new content. <br><br><br><br><pre><code class=\"json\">shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/document/products/1423839849\n{ \n \"hello\" : \"world\" \n}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1424167529\"\nlocation: /_db/_system/_api/document/products/1423839849\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1423839849\", \n \"_rev\" : \"1424167529\", \n \"_key\" : \"1423839849\" \n}\nshell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/document/products/1423839849\n{ \n \"numbers\" : { \n \"one\" : 1, \n \"two\" : 2, \n \"three\" : 3, \n \"empty\" : null \n } \n}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1424757353\"\nlocation: /_db/_system/_api/document/products/1423839849\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1423839849\", \n \"_rev\" : \"1424757353\", \n \"_key\" : \"1423839849\" \n}\nshell> curl --data-binary @- --dump - http://localhost:8529/_api/document/products/1423839849\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1424757353\"\n\n{ \n \"one\" : \"world\", \n \"hello\" : \"world\", \n \"numbers\" : { \n \"empty\" : null, \n \"one\" : 1, \n \"two\" : 2, \n \"three\" : 3 \n }, \n \"_id\" : \"products/1423839849\", \n \"_rev\" : \"1424757353\", \n \"_key\" : \"1423839849\" \n}\nshell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/document/products/1423839849?keepNull=false\n{ \n \"hello\" : null, \n \"numbers\" : { \n \"four\" : 4 \n } \n}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1425216105\"\nlocation: /_db/_system/_api/document/products/1423839849\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1423839849\", \n \"_rev\" : \"1425216105\", \n \"_key\" : \"1423839849\" \n}\nshell> curl --data-binary @- --dump - http://localhost:8529/_api/document/products/1423839849\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1425216105\"\n\n{ \n \"one\" : \"world\", \n \"numbers\" : { \n \"empty\" : null, \n \"one\" : 1, \n \"two\" : 2, \n \"three\" : 3, \n \"four\" : 4 \n }, \n \"_id\" : \"products/1423839849\", \n \"_rev\" : \"1425216105\", \n \"_key\" : \"1423839849\" \n}\n</code></pre><br><br><br>",
|
|
"nickname": "PatchDocument"
|
|
}
|
|
],
|
|
"path": "/_api/document/{document-handle}"
|
|
},
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "is returned if the document was deleted successfully and <em>waitForSync</em> was <em>true</em>. <br><br>",
|
|
"code": "200"
|
|
},
|
|
{
|
|
"reason": "is returned if the document was deleted successfully and <em>waitForSync</em> was <em>false</em>. <br><br>",
|
|
"code": "202"
|
|
},
|
|
{
|
|
"reason": "is returned if the collection or the document was not found. The response body contains an error document in this case. <br><br>",
|
|
"code": "404"
|
|
},
|
|
{
|
|
"reason": "is returned if a \"If-Match\" header or <em>rev</em> is given and the found document has a different version. The response will also contain the found document's current revision in the <em>_rev</em> attribute. Additionally, the attributes <em>_id</em> and <em>_key</em> will be returned. <br><br>",
|
|
"code": "412"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "path",
|
|
"required": "true",
|
|
"name": "document-handle",
|
|
"description": "Deletes the document identified by <em>document-handle</em>. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "rev",
|
|
"description": "You can conditionally delete a document based on a target revision id by using the <em>rev</em> URL parameter. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "policy",
|
|
"description": "To control the update behavior in case there is a revision mismatch, you can use the <em>policy</em> parameter. This is the same as when replacing documents (see replacing documents for more details). <br><br>"
|
|
},
|
|
{
|
|
"dataType": "Boolean",
|
|
"paramType": "query",
|
|
"required": "false",
|
|
"name": "waitForSync",
|
|
"description": "Wait until document has been synced to disk. <br><br>"
|
|
},
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "header",
|
|
"name": "If-Match",
|
|
"description": "You can conditionally delete a document based on a target revision id by using the <em>if-match</em> HTTP header. <br><br>"
|
|
}
|
|
],
|
|
"notes": "The body of the response contains a JSON object with the information about the handle and the revision. The attribute <em>_id</em> contains the known <em>document-handle</em> of the deleted document, the attribute <em>_rev</em> contains the document revision. <br><br> If the <em>waitForSync</em> parameter is not specified or set to <em>false</em>, then the collection's default <em>waitForSync</em> behavior is applied. The <em>waitForSync</em> URL parameter cannot be used to disable synchronisation for collections that have a default <em>waitForSync</em> value of <em>true</em>. <br><br>",
|
|
"summary": " Deletes document",
|
|
"httpMethod": "DELETE",
|
|
"examples": "<br><br> Using document handle: <br><br><br><br><pre><code class=\"json\">shell> curl -X DELETE --data-binary @- --dump - http://localhost:8529/_api/document/products/1425805929\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1425805929\", \n \"_rev\" : \"1425805929\", \n \"_key\" : \"1425805929\" \n}\n</code></pre><br><br><br> Unknown document handle: <br><br><br><br><pre><code class=\"json\">shell> curl -X DELETE --data-binary @- --dump - http://localhost:8529/_api/document/products/1426526825\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"document /_api/document/products/1426526825 not found\", \n \"code\" : 404, \n \"errorNum\" : 1202 \n}\n</code></pre><br><br><br> Revision conflict: <br><br><br><br><pre><code class=\"json\">shell> curl -X DELETE --header 'If-Match: \"1427706473\"' --dump - http://localhost:8529/_api/document/products/1427378793\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\netag: \"1427378793\"\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/1427378793\", \n \"_rev\" : \"1427378793\", \n \"_key\" : \"1427378793\" \n}\n</code></pre><br><br><br>",
|
|
"nickname": "DeletesDocument"
|
|
}
|
|
],
|
|
"path": "/_api/document/{document-handle}"
|
|
}
|
|
]
|
|
}
|