mirror of https://gitee.com/bigwinds/arangodb
157 lines
8.7 KiB
HTML
157 lines
8.7 KiB
HTML
<html><head><title>ArangoDB Manual</title> <style media="screen" type="text/css" style="display:none">body{background-color:white;font:13px Helvetica,arial,freesans,clean,sans-serif;line-height:1.4;color:#333;}#access{font-size:16px;margin-left:12px;display:block;margin-left:10px;margin-right:10px;background-color:#F3F1EE!important;}#access a{border-right:1px solid #DBDEDF;color:#A49F96;display:block;line-height:38px;padding:0 10px;text-decoration:none;}#navigation ul{text-transform:uppercase;list-style:none;margin:0;}#navigation li{float:left;position:relative;}#container{width:920px;margin:0 auto;}a{color:#4183C4;text-decoration:none;}.contents h2{font-size:24px;border-bottom:1px solid #CCC;color:black;}.contents h1{font-size:33px;border-bottom:1px solid #CCC;color:black;}.clearfix:after{content:".";display:block;clear:both;font-size:0;height:0;visibility:hidden;}/**/ *:first-child+html .clearfix{min-height:0;}/**/ * html .clearfix{height:1%;}</style></head><body><div id="container"><img src="images/logo_arangodb.png" width="397" height="67" alt="ArangoDB"><div id="access" role="navigation"><div id="navigation"><ul id="menu-ahome" class="menu"><li><a href="Home.html">Table of contents</a></li> <li><a href="http://www.arangodb.org">ArangoDB homepage</a></li></ul></div><div class="clearfix"></div></div><div>
|
|
<!-- Generated by Doxygen 1.7.5.1 -->
|
|
</div>
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<h1>REST Interface for storing key-value pairs </h1> </div>
|
|
</div>
|
|
<div class="contents">
|
|
<div class="textblock"><h2><a class="anchor" id="Key-ValueCreate"></a>
|
|
Create a new key-value pair in the data store.</h2>
|
|
<p>Creates a new key-value pair with the given key, the data passed in content and optional attributes passed in the header. If a key-value pair with the same key exists in the data store, the request returns an error.</p>
|
|
<p><a class="anchor" id="Key-ValuePost"></a> <code><b>POST /_api/key/<em>collection-name</em>/<em>key</em></b></code></p>
|
|
<p>Optional Attributes:</p>
|
|
<ul>
|
|
<li><code>x-voc-expires</code> Expiry-date for this key-value pair.</li>
|
|
<li><code>x-voc-extended</code> A JSON-object of one or more attributes to be attached to the key-value pair.</li>
|
|
<li>TODO <code>binary data</code></li>
|
|
</ul>
|
|
<p>If the document was created successfully, then a <code>HTTP 201</code> is returned.</p>
|
|
<p>If the <em>collection-name</em> is unknown, then a <code>HTTP 404</code> is returned.</p>
|
|
<p>If the <em>key</em> is used, then a <code>HTTP 404</code> is returned.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<p>Create a key-value pair</p>
|
|
<div class="fragment"><pre class="fragment"> POST /_api/key/example_collection/example_key1 HTTP/1.1
|
|
Host: localhost:9000
|
|
x-voc-expires: 2011-09-29T08:00:00Z
|
|
x-voc-extended: {"option1":35,"option2":"x"}
|
|
Content-Length: 2
|
|
|
|
12
|
|
</pre></div><p>Response (Success)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 201 Created
|
|
connection: Keep-Alive
|
|
content-type: application/json
|
|
server: triagens GmbH High-Performance HTTP Server
|
|
content-length: 62
|
|
|
|
{"saved":true,"_id":"155630:9500735","error":false,"code":201}
|
|
</pre></div><p>Response (Failure)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 404 Bad Request
|
|
content-type: application/json
|
|
connection: Keep-Alive
|
|
server: triagens GmbH High-Performance HTTP Server
|
|
content-length: 75
|
|
|
|
{"error":true,"code":404,"errorNum":41304,"errorMessage":"Use PUT to change value"}
|
|
</pre></div><h2><a class="anchor" id="Key-ValueChange"></a>
|
|
Creates or changes the value for a given key.</h2>
|
|
<p>Sets the value associated with key to the new data passed in content.</p>
|
|
<p><a class="anchor" id="Key-ValuePut"></a> <code><b>PUT /_api/key/<em>collection-name</em>/<em>key</em></b></code></p>
|
|
<p>Optional parameter:</p>
|
|
<ul>
|
|
<li><code>?create=1</code> When set to 1 database will create keys if they do not exist. When set to 0 (default) it will return an error if a key does not exist.</li>
|
|
</ul>
|
|
<p>If the document was updated successfully, then a <code>HTTP 202</code> is returned.</p>
|
|
<p>If the <em>collection-name</em> is unknown, then a <code>HTTP 404</code> is returned.</p>
|
|
<p>If the <em>key</em> is not found and <code>?create=0</code>, then a <code>HTTP 404</code> is returned.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<p>Update a key-value pair</p>
|
|
<div class="fragment"><pre class="fragment"> PUT /_api/key/example_collection/example_key1 HTTP/1.1
|
|
Host: localhost:9000
|
|
x-voc-expires: 2011-09-29T08:00:00Z
|
|
x-voc-extended: {"option1":35,"option2":"x"}
|
|
Content-Length: 2
|
|
|
|
13
|
|
</pre></div><p>Response (Success)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 202 Accepted
|
|
connection: Keep-Alive
|
|
content-type: application/json
|
|
server: triagens GmbH High-Performance HTTP Server
|
|
content-length: 41
|
|
|
|
{"changed":true,"error":false,"code":202}
|
|
</pre></div><p>Response (Failure)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 404 Bad Request
|
|
...
|
|
|
|
{"error":true,"code":404,"errorNum":41404,"errorMessage":"Key value pair not found"}
|
|
</pre></div><h2><a class="anchor" id="Key-ValueReturn"></a>
|
|
Returns the value associated with a given key.</h2>
|
|
<p>Returns the value associated with the key in content. The Attributes of the key-value pair are returned in the header.</p>
|
|
<p><a class="anchor" id="Key-ValueGet"></a> <code><b>GET /_api/key/<em>collection-name</em>/<em>key</em></b></code></p>
|
|
<p>If the document was found, then a <code>HTTP 200</code> is returned.</p>
|
|
<p>If the <em>collection-name</em> is unknown, then a <code>HTTP 404</code> is returned.</p>
|
|
<p>If the <em>key</em> is not found, then a <code>HTTP 404</code> is returned.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<p>Get a key-value pair</p>
|
|
<div class="fragment"><pre class="fragment"> GET /_api/key/example_collection/example_key1 HTTP/1.1
|
|
Host: localhost:9000
|
|
</pre></div><p>Response (Success) with attributes</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 200 OK
|
|
x-voc-created: 2010-09-15T09:35:01Z
|
|
x-voc-expires: 2011-09-29T08:00:00Z
|
|
x-voc-extended: {"option1":35,"option2":"x"}
|
|
...
|
|
|
|
13
|
|
</pre></div><p>Response (Failure)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 404 Bad Request
|
|
...
|
|
|
|
{"error":true,"code":404,"errorNum":41404,"errorMessage":"Key value pair not found"}
|
|
</pre></div><h2><a class="anchor" id="Key-ValueRemove"></a>
|
|
This function deletes a key-value pair from the data store.</h2>
|
|
<p>Deletes the key-value pair with key from the store. Deletions cannot be undone!</p>
|
|
<p><a class="anchor" id="Key-ValueDelete"></a> <code><b>DELETE /_api/key/<em>collection-name</em>/<em>key</em></b></code></p>
|
|
<p>This function does not support any header parameters.</p>
|
|
<p>If the document was found and deleted, then a <code>HTTP 200</code> is returned.</p>
|
|
<p>If the <em>collection-name</em> is unknown, then a <code>HTTP 404</code> is returned.</p>
|
|
<p>If the <em>key</em> is not found, then a <code>HTTP 404</code> is returned.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<p>Delete a key-value pair</p>
|
|
<div class="fragment"><pre class="fragment"> DELETE /_api/key/example_collection/example_key1 HTTP/1.1
|
|
Host: localhost:9000
|
|
</pre></div><p>Response (Success)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 200 OK
|
|
...
|
|
|
|
{"removed":true,"error":false,"code":202}
|
|
</pre></div><p>Response (Failure)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 404 Bad Request
|
|
...
|
|
|
|
{"error":true,"code":404,"errorNum":41404,"errorMessage":"Key value pair not found"}
|
|
</pre></div><h2><a class="anchor" id="Key-ValueLookup"></a>
|
|
This function returns all keys matching a given prefix.</h2>
|
|
<p>Retrieves all values that begin with key and returns them as a JSON-array in content.</p>
|
|
<p><a class="anchor" id="Key-ValueSearch"></a> <code><b>GET /_api/keys/<em>collection-name</em>/<em>prefix</em></b></code></p>
|
|
<p><em>prefix</em> (=beginning of word) to search for. Note that any /-characters contained in key are considered part of the key and have no special meaning.</p>
|
|
<p>TODO Optional parameter:</p>
|
|
<ul>
|
|
<li><code>?filter=Filter Expression</code> Return only those keys that match the given filter expression (have certain attributes). Please note that the filter expression has to be URL-encoded</li>
|
|
</ul>
|
|
<p>If the <em>collection-name</em> is unknown, then a <code>HTTP 404</code> is returned.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<p>Find keys by prefix</p>
|
|
<div class="fragment"><pre class="fragment"> GET /_api/keys/example_collection/example_key HTTP/1.1
|
|
Host: localhost:9000
|
|
</pre></div><p>Response (Success)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 200 OK
|
|
...
|
|
|
|
["example_keyboard","example_keystone"]
|
|
</pre></div><p>Response (Failure)</p>
|
|
<div class="fragment"><pre class="fragment"> HTTP/1.1 404 Bad Request
|
|
...
|
|
|
|
{"error":true,"code":404,"errorNum":41404,"errorMessage":"Collection not found"}
|
|
</pre></div> </div></div>
|
|
</div></body></html>
|