This is an introduction to ArangoDB's interface for edges and how handle edges from the JavaScript shell arangosh
. For other languages see the corresponding language API.
Edge: Edges in ArangoDB are special documents. In addition to the internal attributes _id
and _rev
, they have two attributes _form
and _to
, which contain document handles namely the start-point and the end-point of the edge.
Edge Collection: Edge collections are special collection where edge documents live. Instead of using db
, one must use edges
to access the edge collection.
edge-collection.save(from, to, document)
Examples
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" }
edge-collection.edges(vertex)
edges
operator finds all edges starting from (outbound) or ending in (inbound) vertex.
edge-collection.edges(vertices)
edges
operator finds all edges starting from (outbound) or ending in (inbound) a document from vertices, which must a list of documents or document handles.
Examples
arango> db.relation.edges("86294/1593622"); [ { "_id" : "1659158/3100950", "_rev" : 3100950, "_from" : "86294/1528086", "_to" : "86294/1593622", "label" : "knows" } ]
edge-collection.inEdges(vertex)
edges
operator finds all edges ending in (inbound) vertex.
edge-collection.inEdges(vertices)
edges
operator finds all edges ending in (inbound) a document from vertices, which must a list of documents or document handles.
Examples
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" } ]
edge-collection.outEdges(vertex)
edges
operator finds all edges starting from (outbound) vertices.
edge-collection.outEdges(vertices)
edges
operator finds all edges starting from (outbound) a document from vertices, which must a list of documents or document handles.
Examples
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"); [ ]