mirror of https://gitee.com/bigwinds/arangodb
113 lines
6.1 KiB
HTML
113 lines
6.1 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>Handling Edges </h1> </div>
|
|
</div>
|
|
<div class="contents">
|
|
<div class="textblock"><p>This is an introduction to ArangoDB's interface for edges and how handle edges from the JavaScript shell <code>arangosh</code>. For other languages see the corresponding language API.</p>
|
|
<hr/>
|
|
<ul>
|
|
<li>
|
|
<a class="el" href="ShellEdge.html">Handling Edges</a> <ul>
|
|
<li>
|
|
<a class="el" href="ShellEdge.html#ShellEdgeIntro">Edges, Identifiers, Handles</a> </li>
|
|
<li>
|
|
<a class="el" href="ShellEdge.html#ShellEdgeShell">Working with Edges</a> <ul>
|
|
<li>
|
|
<a class="el" href="ShellEdge.html#ShellEdgeCreate">edge-collection.save</a> </li>
|
|
<li>
|
|
<a class="el" href="ShellEdge.html#ShellEdgeEdges">edge-collection.edges</a> </li>
|
|
<li>
|
|
<a class="el" href="ShellEdge.html#ShellEdgeInEdges">edge-collection.inEdges</a> </li>
|
|
<li>
|
|
<a class="el" href="ShellEdge.html#ShellEdgeOutEdges">edge-collection.outEdges</a> </li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
<h2><a class="anchor" id="ShellEdgeIntro"></a>
|
|
Edges, 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>
|
|
<p><b>Edge Collection</b>: Edge collections are special collection where edge documents live. Instead of using <code>db</code>, one must use <code>edges</code> to access the edge collection. </p>
|
|
<h2><a class="anchor" id="ShellEdgeShell"></a>
|
|
Working with Edges</h2>
|
|
<p><a class="anchor" id="ShellEdgeCreate"></a> <hr/>
|
|
<code><b><em>edge-collection</em>.save(<em>from</em>, <em>to</em>, <em>document</em>)</b></code><hr/>
|
|
Saves a new edge and returns the document-handle. <em>from</em> and <em>to</em> must be documents or document references.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<div class="fragment"><pre class="fragment">arango> v1 = db.vertex.save({ name : "vertex 1" });
|
|
{ "_id" : "86294/1528086", "_rev" : 1528086 }
|
|
arango> v2 = db.vertex.save({ name : "vertex 2" });
|
|
{ "_id" : "86294/1593622", "_rev" : 1593622 }
|
|
arango> e1 = db.relation.save(v1, v2, { label : "knows" });
|
|
{ "_id" : "1659158/3100950", "_rev" : 3100950 }
|
|
arango> db._document(e1);
|
|
{ "_id" : "1659158/3100950", "_rev" : 3100950, "_from" : "86294/1528086", "_to" : "86294/1593622", "label" : "knows" }
|
|
</pre></div> <p><a class="anchor" id="ShellEdgeEdges"></a> <hr/>
|
|
<code><b><em>edge-collection</em>.edges(<em>vertex</em>)</b></code><hr/>
|
|
The <code>edges</code> operator finds all edges starting from (outbound) or ending in (inbound) <em>vertex</em>.</p>
|
|
<hr/>
|
|
<code><b><em>edge-collection</em>.edges(<em>vertices</em>)</b></code><hr/>
|
|
The <code>edges</code> operator finds all edges starting from (outbound) or ending in (inbound) a document from <em>vertices</em>, which must a list of documents or document handles.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<div class="fragment"><pre class="fragment">arango> db.relation.edges("86294/1593622");
|
|
[
|
|
{
|
|
"_id" : "1659158/3100950",
|
|
"_rev" : 3100950,
|
|
"_from" : "86294/1528086",
|
|
"_to" : "86294/1593622",
|
|
"label" : "knows"
|
|
}
|
|
]
|
|
</pre></div> <p><a class="anchor" id="ShellEdgeInEdges"></a> <hr/>
|
|
<code><b><em>edge-collection</em>.inEdges(<em>vertex</em>)</b></code><hr/>
|
|
The <code>edges</code> operator finds all edges ending in (inbound) <em>vertex</em>.</p>
|
|
<hr/>
|
|
<code><b><em>edge-collection</em>.inEdges(<em>vertices</em>)</b></code><hr/>
|
|
The <code>edges</code> operator finds all edges ending in (inbound) a document from <em>vertices</em>, which must a list of documents or document handles.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<div class="fragment"><pre class="fragment">arango> db.relation.inEdges("86294/1528086");
|
|
[ ]
|
|
arango> db.relation.inEdges("86294/1593622");
|
|
[
|
|
{
|
|
"_id" : "1659158/3100950",
|
|
"_rev" : 3100950,
|
|
"_from" : "86294/1528086",
|
|
"_to" : "86294/1593622",
|
|
"label" :
|
|
"knows"
|
|
}
|
|
]
|
|
</pre></div> <p><a class="anchor" id="ShellEdgeOutEdges"></a> <hr/>
|
|
<code><b><em>edge-collection</em>.outEdges(<em>vertex</em>)</b></code><hr/>
|
|
The <code>edges</code> operator finds all edges starting from (outbound) <em>vertices</em>.</p>
|
|
<hr/>
|
|
<code><b><em>edge-collection</em>.outEdges(<em>vertices</em>)</b></code><hr/>
|
|
The <code>edges</code> operator finds all edges starting from (outbound) a document from <em>vertices</em>, which must a list of documents or document handles.</p>
|
|
<p><b>Examples</b><br/>
|
|
</p>
|
|
<div class="fragment"><pre class="fragment">arango> db.relation.outEdges("86294/1528086");
|
|
[
|
|
{
|
|
"_id" : "1659158/3100950",
|
|
"_rev" : 3100950,
|
|
"_from" : "86294/1528086",
|
|
"_to" : "86294/1593622",
|
|
"label" :
|
|
"knows"
|
|
}
|
|
]
|
|
arango> db.relation.outEdges("86294/1593622");
|
|
[ ]
|
|
</pre></div> </div></div>
|
|
</div></body></html>
|