1
0
Fork 0
arangodb/Doxygen/doc/RestEdge.html

207 lines
10 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 Edges </h1> </div>
</div>
<div class="contents">
<div class="textblock"><p>This is an introduction to ArangoDB's REST interface for edges.</p>
<p>AvocacadoDB offers also some graph functionality. A graph consists of nodes, edges and properties. ArangoDB stores the information how the nodes relate to each other aside from the properties.</p>
<p>So a graph data model always consists of two collections: the relations between the nodes in the graphs are stored in an "edges collection", the nodes in the graph are stored in documents in regular collections.</p>
<p>Example:</p>
<ul>
<li>the edge collection stores the information that a company's reception is sub-unit to the services unit and the services unit is sub-unit to the CEO. You would express this relationship with the <code>_from</code> and <code>_to</code> property</li>
</ul>
<ul>
<li>the "normal" collection stores all the properties about the reception, e.g. that 20 people are working there and the room number etc.</li>
</ul>
<p><code>_from</code> is the document handle of the linked vertex (incoming relation), <code>_to</code> is the document handle of the linked vertex (outgoing relation).</p>
<hr/>
<ul>
<li>
<a class="el" href="RestEdge.html">REST Interface for Edges</a> <ul>
<li>
<a class="el" href="RestEdge.html#RestEdgeIntro">Documents, Identifiers, Handles</a> </li>
<li>
<a class="el" href="RestEdge.html#RestEdgeResource">Address and ETag of an Edge</a> </li>
<li>
<a class="el" href="RestEdge.html#RestEdgeHttp">Working with Edges using REST</a> <ul>
<li>
<a class="el" href="RestEdge.html#RestEdgeRead">GET /_api/edge/document-handle</a> </li>
<li>
<a class="el" href="RestEdge.html#RestEdgeCreate">POST /_api/edge?collection=collection-identifier&amp;from=from-handle&amp;to=to-handle</a> </li>
<li>
<a class="el" href="RestEdge.html#RestEdgeUpdate">PUT /_api/edge/document-handle</a> </li>
<li>
<a class="el" href="RestEdge.html#RestEdgeDelete">DELETE /_api/edge/document-handle</a> </li>
<li>
<a class="el" href="RestEdge.html#RestEdgeHead">HEAD /_api/edge/document-handle</a> </li>
<li>
<a class="el" href="RestEdge.html#RestEdgeEdges">GET /_api/edges/collection-identifier?vertex=vertex-handle&amp;directory=direction</a> </li>
</ul>
</li>
</ul>
</li>
</ul>
<hr/>
<h2><a class="anchor" id="RestEdgeIntro"></a>
Documents, Identifiers, Handles</h2>
<p><b>Edge</b>: Edges in ArangoDB are special documents. In addition to the internal attributes <code>_id</code> and <code>_rev</code>, they have two attributes <code>_form</code> and <code>_to</code>, which contain document handles namely the start-point and the end-point of the edge. </p>
<h2><a class="anchor" id="RestEdgeResource"></a>
Address and ETag of an Edge</h2>
<p>All documents in ArangoDB have a document handle. This handle uniquely defines a document and is managed by ArangoDB. All documents are found under the URI</p>
<p><code><a href="http://">http://</a><em>server</em>:<em>port</em>/_api/document/<em>document-handle</em></code></p>
<p>For edges you can use the special address</p>
<p><code><a href="http://">http://</a><em>server</em>:<em>port</em>/_api/edge/<em>document-handle</em></code></p>
<p>For example: Assume that the document handle, which is stored in the <code>_id</code> field of the edge, is <code>7254820/362549736</code>, then the URL of that edge is:</p>
<p><code><a href="http://localhost:8529/_api/edge/7254820/362549736">http://localhost:8529/_api/edge/7254820/362549736</a></code></p>
<h2><a class="anchor" id="RestEdgeHttp"></a>
Working with Edges using REST</h2>
<p><a class="anchor" id="RestEdgeRead"></a> <hr/>
<em>GET /_api/edge</em> (reads an edge)<hr/>
<br/>
<code><b>GET /_api/edge/<em>document-handle</em></b></code></p>
<p>See <a class="el" href="RestDocument.html">REST Interface for Documents</a> for details.</p>
<p><a class="anchor" id="RestEdgeCreate"></a> <hr/>
<em>POST /_api/edge</em> (creates an edge)<hr/>
<br/>
<code><b>POST /_api/edge?collection=<em>collection-identifier</em>&amp;from=<em>from-handle</em>&amp;to=<em>to-handle</em></b></code></p>
<p>Creates a new edge in the collection identified by the <em>collection-identifier</em>. A JSON representation of the document must be passed as the body of the POST request. The object handle of the start point must be passed in <em>from-handle</em>. The object handle of the end point must be passed in <em>to-handle</em>.</p>
<p>In all other respects the method works like <code>POST /document</code>, see <a class="el" href="RestDocument.html">REST Interface for Documents</a> for details.</p>
<p>If you request such an edge, the returned document will also contain the attributes <code>_from</code> and <code>_to</code>.</p>
<p><b>Examples</b><br/>
</p>
<p>Create an edge:</p>
<div class="fragment"><pre class="fragment">&gt; curl --data @- -X POST --dump - http://localhost:8529/_api/edge?collection=7848004&amp;from=7848004/9289796&amp;to=7848004/9355332
{ "e" : 1 }
HTTP/1.1 201 Created
content-type: application/json; charset=utf-8
location: /_api/document/7848004/9683012
etag: "9683012"
{
"_rev": 9683012,
"_id": "7848004/9683012",
"error": false
}
</pre></div><p>Read an edge:</p>
<div class="fragment"><pre class="fragment">&gt; curl -X GET --dump - http://localhost:8529/_api/edge/7848004/9683012
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
etag: "9683012"
{
"_from": "7848004/9289796",
"_rev": 9683012,
"_to": "7848004/9355332",
"_id": "7848004/9683012",
"e": 1
}
</pre></div> <p><a class="anchor" id="RestEdgeUpdate"></a> <hr/>
<em>PUT /_api/edge</em> (updates an edge)<hr/>
<br/>
<code><b>PUT /_api/edge/<em>document-handle</em></b></code></p>
<p>See <a class="el" href="RestDocument.html">REST Interface for Documents</a> for details.</p>
<p><a class="anchor" id="RestEdgeDelete"></a> <hr/>
<em>DELETE /_api/edge</em> (deletes an edge)<hr/>
<br/>
<code><b>DELETE /_api/edge/<em>document-handle</em></b></code></p>
<p>See <a class="el" href="RestDocument.html">REST Interface for Documents</a> for details.</p>
<p><a class="anchor" id="RestEdgeHead"></a> <hr/>
<em>GET /_api/edge</em> (reads an edge header)<hr/>
<br/>
<code><b>HEAD /_api/edge/<em>document-handle</em></b></code></p>
<p>See <a class="el" href="RestDocument.html">REST Interface for Documents</a> for details.</p>
<p><a class="anchor" id="RestEdgeEdges"></a> <hr/>
<em>GET /_api/edges</em> (reads in- or outbound edges)<hr/>
<br/>
<code><b>GET /_api/edges/<em>collection-identifier</em>?vertex=<em>vertex-handle</em>&amp;direction=any</b></code></p>
<p>Returns the list of edges starting or ending in the vertex identified by <em>vertex-handle</em>.</p>
<p><code><b>GET /_api/edges/<em>collection-identifier</em>?vertex=<em>vertex-handle</em>&amp;direction=in</b></code></p>
<p>Returns the list of edges ending in the vertex identified by <em>vertex-handle</em>.</p>
<p><code><b>GET /_api/edges/<em>collection-identifier</em>?vertex=<em>vertex-handle</em>&amp;direction=out</b></code></p>
<p>Returns the list of edges starting in the vertex identified by <em>vertex-handle</em>.</p>
<p><b>Examples</b><br/>
</p>
<p>Any direction</p>
<div class="fragment"><pre class="fragment">&gt; curl -X GET --dump - http://localhost:8529/_api/edges/17501660?vertex=17501660/18419164
HTTP/1.1 200 OK
content-type: application/json
{
"edges": [
{
"_from": "17501660/18419164",
"_rev": 19140060,
"_to": "17501660/19008988",
"_id": "17501660/19140060"
},
{
"_from": "17501660/18419164",
"_rev": 19336668,
"_to": "17501660/19008988",
"_id": "17501660/19336668",
"e": 1
},
{
"_from": "17501660/19008988",
"_rev": 19402204,
"_to": "17501660/18419164",
"_id": "17501660/19402204",
"e": 2
}
],
"code": 200,
"error": false
}
</pre></div><p>In edges</p>
<div class="fragment"><pre class="fragment">&gt; curl -X GET --dump - http://localhost:8529/_api/edges/17501660?vertex=17501660/18419164&amp;direction=in
HTTP/1.1 200 OK
content-type: application/json
{
"edges": [
{
"_from": "17501660/19008988",
"_rev": 19402204,
"_to": "17501660/18419164",
"_id": "17501660/19402204",
"e": 2
}
],
"code": 200,
"error": false
}
</pre></div><p>Out edges</p>
<div class="fragment"><pre class="fragment">&gt; curl -X GET --dump - http://localhost:8529/_api/edges/17501660?vertex=17501660/18419164&amp;direction=out
HTTP/1.1 200 OK
content-type: application/json
{
"edges": [
{
"_from": "17501660/18419164",
"_rev": 19336668,
"_to": "17501660/19008988",
"_id": "17501660/19336668",
"e": 1
},
{
"_from": "17501660/18419164",
"_rev": 19140060,
"_to": "17501660/19008988",
"_id": "17501660/19140060"
}
],
"code": 200,
"error": false
}
</pre></div> </div></div>
</div></body></html>