Graph Management
How to manage named graphs of the type General Graph
This chapter describes the JavaScript interface for creating and modifying named graphs.
Edge Definitions
An edge definition is always a directed relation of a graph. Each graph can have arbitrary many relations defined within the edge definitions array.
Initialize the List
Create a list of edge definitions to construct a graph:
graph_module._edgeDefinitions(relation1, relation2, ..., relationN)
relation(object, optional): An object representing a definition of one relation in the graph
The list of edge definitions of a graph can be managed by the graph module itself. This function is the entry point for the management and returns the correct list.
Examples
var graph_module = require("@arangodb/general-graph");
var directed_relation = graph_module._relation("lives_in", "user", "city");
var undirected_relation = graph_module._relation("knows", "user", "user");
var edgedefinitions = graph_module._edgeDefinitions(directed_relation, undirected_relation);
edgedefinitions;Show output
[
{
"collection" : "lives_in",
"from" : [
"user"
],
"to" : [
"city"
]
},
{
"collection" : "knows",
"from" : [
"user"
],
"to" : [
"user"
]
}
]Extend the List
Extend the list of edge definitions to construct a graph:
graph_module._extendEdgeDefinitions(edgeDefinitions, relation1, relation2, ..., relationN)
edgeDefinitions(array): A list of relation definition objects.relationX(object): An object representing a definition of one relation in the graph
In order to add more edge definitions to the graph before creating it, this function can be used to add more definitions to the initial list.
Examples
var graph_module = require("@arangodb/general-graph");
var directed_relation = graph_module._relation("lives_in", "user", "city");
var undirected_relation = graph_module._relation("knows", "user", "user");
var edgedefinitions = graph_module._edgeDefinitions(directed_relation);
graph_module._extendEdgeDefinitions(edgedefinitions, undirected_relation);
edgedefinitions;Show output
[
{
"collection" : "lives_in",
"from" : [
"user"
],
"to" : [
"city"
]
},
{
"collection" : "knows",
"from" : [
"user"
],
"to" : [
"user"
]
}
]Relation
Define a directed relation:
graph_module._relation(relationName, fromVertexCollections, toVertexCollections)
relationName(string): The name of the edge collection where the edges should be stored. It is created if it does not exist yet.fromVertexCollections(string|array): One or a list of collection names. Source nodes for the edges have to be stored in these collections. Collections are created if they do not exist.toVertexCollections(string|array): One or a list of collection names. Target nodes for the edges have to be stored in these collections. Collections are created if they do not exist.
The relationName defines the name of this relation and references to the
underlying edge collection. The fromVertexCollections is an Array of document
collections holding the start nodes. The toVertexCollections is an array
of document collections holding the target nodes. Relations are only allowed
in the direction from any collection in fromVertexCollections to any
collection in toVertexCollections.
Examples
A relation from one node collection to another:
var graph_module = require("@arangodb/general-graph");
graph_module._relation("has_bought", "Customer", "Product");Show output
{
"collection" : "has_bought",
"from" : [
"Customer"
],
"to" : [
"Product"
]
}A relation from multiple node collections to multiple others:
var graph_module = require("@arangodb/general-graph");
graph_module._relation("has_bought", ["Customer", "Company"], ["Groceries", "Electronics"]);Show output
{
"collection" : "has_bought",
"from" : [
"Customer",
"Company"
],
"to" : [
"Groceries",
"Electronics"
]
}Edge Definition Options
The following edge definition options are supported:
satellites(array, optional): An array of collection names that is used to create SatelliteCollections for a (Disjoint) SmartGraph using SatelliteCollections. Each array element must be a string and a valid collection name. The collection type cannot be modified later.
Create a Graph
graph_module._create(graphName, edgeDefinitions, orphanCollections)
graphName(string): Unique identifier of the graphedgeDefinitions(array, optional): List of relation definition objectsorphanCollections(array, optional): List of additional node collection names
The creation of a graph requires the name of the graph and a definition of its edges.
For every type of edge definition a convenience method exists that can be used to create a graph. Optionally a list of node collections can be added, which are not used in any edge definition. These collections are referred to as orphan collections within this chapter. All collections used within the creation process are created if they do not exist.
Examples
Create an empty graph, edge definitions can be added at runtime:
var graph_module = require("@arangodb/general-graph");
graph = graph_module._create("myGraph");Show output
{[GeneralGraph]
}Create a graph using an edge collection edges and a single
node collection nodes:
var graph_module = require("@arangodb/general-graph");
var edgeDefinitions = [ { collection: "edges", "from": [ "nodes" ], "to" : [ "nodes" ] } ];
graph = graph_module._create("myGraph", edgeDefinitions);Show output
{[GeneralGraph]
"edges" : [ArangoCollection 84855, "edges" (type edge, status loaded)],
"nodes" : [ArangoCollection 84854, "nodes" (type document, status loaded)]
}Create a graph with edge definitions and orphan collections:
var graph_module = require("@arangodb/general-graph");
graph = graph_module._create("myGraph", [
graph_module._relation("myRelation", ["male", "female"], ["male", "female"])
], ["sessions"]);Show output
{[GeneralGraph]
"myRelation" : [ArangoCollection 84904, "myRelation" (type edge, status loaded)],
"female" : [ArangoCollection 84903, "female" (type document, status loaded)],
"male" : [ArangoCollection 84902, "male" (type document, status loaded)],
"sessions" : [ArangoCollection 84901, "sessions" (type document, status loaded)]
}Complete Example to Create a Graph
Example call:
var graph_module = require("@arangodb/general-graph");
var edgeDefinitions = graph_module._edgeDefinitions();
graph_module._extendEdgeDefinitions(edgeDefinitions, graph_module._relation("friend_of", "Customer", "Customer"));
graph_module._extendEdgeDefinitions(edgeDefinitions, graph_module._relation(
"has_bought", ["Customer", "Company"], ["Groceries", "Electronics"])
);
graph_module._create("myStore", edgeDefinitions);Show output
{[GeneralGraph]
"friend_of" : [ArangoCollection 84984, "friend_of" (type edge, status loaded)],
"Customer" : [ArangoCollection 84981, "Customer" (type document, status loaded)],
"has_bought" : [ArangoCollection 84983, "has_bought" (type edge, status loaded)],
"Company" : [ArangoCollection 84982, "Company" (type document, status loaded)],
"Electronics" : [ArangoCollection 84980, "Electronics" (type document, status loaded)],
"Groceries" : [ArangoCollection 84979, "Groceries" (type document, status loaded)]
}Alternative call:
var graph_module = require("@arangodb/general-graph");
var edgeDefinitions = graph_module._edgeDefinitions(
graph_module._relation("friend_of", ["Customer"], ["Customer"]),
graph_module._relation("has_bought", ["Customer", "Company"], ["Groceries", "Electronics"])
);
graph_module._create("myStore", edgeDefinitions);Show output
{[GeneralGraph]
"friend_of" : [ArangoCollection 85067, "friend_of" (type edge, status loaded)],
"Customer" : [ArangoCollection 85064, "Customer" (type document, status loaded)],
"has_bought" : [ArangoCollection 85066, "has_bought" (type edge, status loaded)],
"Company" : [ArangoCollection 85065, "Company" (type document, status loaded)],
"Electronics" : [ArangoCollection 85063, "Electronics" (type document, status loaded)],
"Groceries" : [ArangoCollection 85062, "Groceries" (type document, status loaded)]
}List available Graphs
Lists all graph names stored in this database:
graph_module._list()
Lists all graph definitions stored in this database:
graph_module._listObjects()
Examples
List the graph names:
var graph_module = require("@arangodb/general-graph");
graph_module._list();Show output
[
"myGraph",
"myStore"
]List the graph definitions:
var graph_module = require("@arangodb/general-graph");
graph_module._listObjects();Show output
[
{
"_id" : "_graphs/myGraph",
"_key" : "myGraph",
"_rev" : "_kgUuVQS--_",
"edgeDefinitions" : [
{
"collection" : "edges",
"from" : [
"nodes"
],
"to" : [
"nodes"
]
}
],
"orphanCollections" : [ ],
"name" : "myGraph"
},
{
"_id" : "_graphs/myStore",
"_key" : "myStore",
"_rev" : "_kgUuVRS---",
"edgeDefinitions" : [
{
"collection" : "friend_of",
"from" : [
"Customer"
],
"to" : [
"Customer"
]
},
{
"collection" : "has_bought",
"from" : [
"Company",
"Customer"
],
"to" : [
"Electronics",
"Groceries"
]
}
],
"orphanCollections" : [ ],
"name" : "myStore"
}
]Load a Graph
Get a graph by its name:
graph_module._graph(graphName)
graphName(string): Unique identifier of the graph
Examples
var graph_module = require("@arangodb/general-graph");
graph = graph_module._graph("social");Show output
{[GeneralGraph]
"relation" : [ArangoCollection 85342, "relation" (type edge, status loaded)],
"female" : [ArangoCollection 85326, "female" (type document, status loaded)],
"male" : [ArangoCollection 85334, "male" (type document, status loaded)]
}Remove a Graph
Drop a Graph by its name:
graph_module._drop(graphName, dropCollections)
graphName(string): Unique identifier of the graphdropCollections(bool, optional): Define if collections should be dropped (default:false)
This can drop all collections contained in the graph as long as they are not
used within other graphs. To drop the collections only belonging to this graph,
the optional parameter drop-collections has to be set to true.
Examples
Drop a graph and keep collections:
var graph_module = require("@arangodb/general-graph");
graph_module._graph("social");
graph_module._drop("social");
db._collection("female");
db._collection("male");
db._collection("relation");Show output
{[GeneralGraph]
"relation" : [ArangoCollection 85428, "relation" (type edge, status loaded)],
"female" : [ArangoCollection 85412, "female" (type document, status loaded)],
"male" : [ArangoCollection 85420, "male" (type document, status loaded)]
}
[ArangoCollection 85412, "female" (type document, status loaded)]
[ArangoCollection 85420, "male" (type document, status loaded)]
[ArangoCollection 85428, "relation" (type edge, status loaded)]Drop a graph and its collections:
var graph_module = require("@arangodb/general-graph");
graph_module._graph("social");
graph_module._drop("social", true);
db._collection("female");
db._collection("male");
db._collection("relation");Show output
{[GeneralGraph]
"relation" : [ArangoCollection 85505, "relation" (type edge, status loaded)],
"female" : [ArangoCollection 85489, "female" (type document, status loaded)],
"male" : [ArangoCollection 85497, "male" (type document, status loaded)]
}
null
null
nullModify a Graph definition at runtime
After you have created a graph its definition is not immutable. You can still add, delete or modify edge definitions and node collections.
Extend the Edge Definitions
Add another edge definition to the graph:
graph._extendEdgeDefinitions(edgeDefinition, options)
edgeDefinition(object): The relation definition to extend the graphoptions(object): Additional options related to the edge definition itself. See Edge Definition Options.
Extends the edge definitions of a graph. If an orphan collection is used in this
edge definition, it is removed from the orphanage. If the edge collection of
the edge definition to add is already used in the graph or used in a different
graph with different from and/or to collections an error is thrown.
Examples
var graph_module = require("@arangodb/general-graph")
var ed1 = graph_module._relation("myEC1", ["myVC1"], ["myVC2"]);
var ed2 = graph_module._relation("myEC2", ["myVC1"], ["myVC3"]);
var graph = graph_module._create("myGraph", [ed1]);
graph._extendEdgeDefinitions(ed2);
graph = graph_module._graph("myGraph");Show output
{[GeneralGraph]
"myEC1" : [ArangoCollection 85581, "myEC1" (type edge, status loaded)],
"myVC1" : [ArangoCollection 85580, "myVC1" (type document, status loaded)],
"myVC2" : [ArangoCollection 85579, "myVC2" (type document, status loaded)],
"myEC2" : [ArangoCollection 85605, "myEC2" (type edge, status loaded)],
"myVC3" : [ArangoCollection 85604, "myVC3" (type document, status loaded)]
}Modify an Edge Definition
Modify a relation definition:
graph_module._editEdgeDefinitions(edgeDefinition, options)
edgeDefinition(object): The edge definition to replace the existing edge definition with the same attributecollection.options(object): Additional options related to the edge definition itself. See Edge Definition Options.
Edits one relation definition of a graph. The edge definition used as argument replaces the existing edge definition of the graph which has the same collection. Node Collections of the replaced edge definition that are not used in the new definition are transformed to an orphan. Orphans that are used in this new edge definition are deleted from the list of orphans. Other graphs with the same edge definition are modified, too.
Examples
var graph_module = require("@arangodb/general-graph")
var original = graph_module._relation("myEC1", ["myVC1"], ["myVC2"]);
var modified = graph_module._relation("myEC1", ["myVC2"], ["myVC3"]);
var graph = graph_module._create("myGraph", [original]);
graph._editEdgeDefinitions(modified);
graph = graph_module._graph("myGraph");Show output
{[GeneralGraph]
"myEC1" : [ArangoCollection 85684, "myEC1" (type edge, status loaded)],
"myVC2" : [ArangoCollection 85682, "myVC2" (type document, status loaded)],
"myVC3" : [ArangoCollection 85704, "myVC3" (type document, status loaded)],
"myVC1" : [ArangoCollection 85683, "myVC1" (type document, status loaded)]
}Delete an Edge Definition
Delete one relation definition:
graph_module._deleteEdgeDefinition(edgeCollectionName, dropCollection)
edgeCollectionName(string): Name of edge collection in the relation definition.dropCollection(bool, optional): Define if the edge collection should be dropped. Default:false
Deletes a relation definition defined by the edge collection of a graph. If the
collections defined in the edge definition (collection, from, to) are not used
in another edge definition of the graph, they are moved to the orphanage.
Examples
Remove an edge definition but keep the edge collection:
var graph_module = require("@arangodb/general-graph")
var ed1 = graph_module._relation("myEC1", ["myVC1"], ["myVC2"]);
var ed2 = graph_module._relation("myEC2", ["myVC1"], ["myVC3"]);
var graph = graph_module._create("myGraph", [ed1, ed2]);
graph._deleteEdgeDefinition("myEC1");
graph = graph_module._graph("myGraph");
db._collection("myEC1");Show output
{[GeneralGraph]
"myEC2" : [ArangoCollection 85779, "myEC2" (type edge, status loaded)],
"myVC1" : [ArangoCollection 85778, "myVC1" (type document, status loaded)],
"myVC3" : [ArangoCollection 85776, "myVC3" (type document, status loaded)],
"myVC2" : [ArangoCollection 85777, "myVC2" (type document, status loaded)]
}
[ArangoCollection 85780, "myEC1" (type edge, status loaded)]Remove an edge definition and drop the edge collection:
var graph_module = require("@arangodb/general-graph")
var ed1 = graph_module._relation("myEC1", ["myVC1"], ["myVC2"]);
var ed2 = graph_module._relation("myEC2", ["myVC1"], ["myVC3"]);
var graph = graph_module._create("myGraph", [ed1, ed2]);
graph._deleteEdgeDefinition("myEC1", true);
graph = graph_module._graph("myGraph");
db._collection("myEC1");Show output
{[GeneralGraph]
"myEC2" : [ArangoCollection 85874, "myEC2" (type edge, status loaded)],
"myVC1" : [ArangoCollection 85873, "myVC1" (type document, status loaded)],
"myVC3" : [ArangoCollection 85871, "myVC3" (type document, status loaded)],
"myVC2" : [ArangoCollection 85872, "myVC2" (type document, status loaded)]
}
nullExtend Node Collections
Each graph can have an arbitrary amount of node collections, which are not part of any edge definition of the graph. These collections are called orphan collections. If the graph is extended with an edge definition using one of the orphans, it is removed from the set of orphan collection automatically.
Add a Node Collection
Add a node collection to the graph:
graph._addVertexCollection(vertexCollectionName, createCollection, options)
vertexCollectionName(string): Name of node collection.createCollection(bool, optional): Iftrue, the collection is created if it does not exist. Default:trueoptions(object, optional): Additional options related to the edge definition itself. See Edge Definition Options.
Adds a node collection to the set of orphan collections of the graph. If the collection does not exist, it is created. If it is already used by any edge definition of the graph, an error is thrown.
Examples
var graph_module = require("@arangodb/general-graph");
var ed1 = graph_module._relation("myEC1", ["myVC1"], ["myVC2"]);
var graph = graph_module._create("myGraph", [ed1]);
graph._addVertexCollection("myVC3", true);
graph = graph_module._graph("myGraph");Show output
{[GeneralGraph]
"myEC1" : [ArangoCollection 85969, "myEC1" (type edge, status loaded)],
"myVC1" : [ArangoCollection 85968, "myVC1" (type document, status loaded)],
"myVC2" : [ArangoCollection 85967, "myVC2" (type document, status loaded)],
"myVC3" : [ArangoCollection 85989, "myVC3" (type document, status loaded)]
}Get the Orphaned Collections
Get all orphan collections:
graph._orphanCollections()
Returns all node collections of the graph that are not used in any edge definition.
Examples
var graph_module = require("@arangodb/general-graph")
var ed1 = graph_module._relation("myEC1", ["myVC1"], ["myVC2"]);
var graph = graph_module._create("myGraph", [ed1]);
graph._addVertexCollection("myVC3", true);
graph._orphanCollections();Show output
[
"myVC3"
]Remove a Node Collection
Remove a node collection from the graph:
graph._removeVertexCollection(vertexCollectionName, dropCollection)
vertexCollectionName(string): Name of node collection.dropCollection(bool, optional): Iftrue, the collection is dropped if it is not used in any other graph. Default:false
Removes a node collection from the graph. Only collections not used in any relation definition can be removed. Optionally the collection can be deleted, if it is not used in any other graph.
Examples
var graph_module = require("@arangodb/general-graph")
var ed1 = graph_module._relation("myEC1", ["myVC1"], ["myVC2"]);
var graph = graph_module._create("myGraph", [ed1]);
graph._addVertexCollection("myVC3", true);
graph._addVertexCollection("myVC4", true);
graph._orphanCollections();
graph._removeVertexCollection("myVC3");
graph._orphanCollections();Show output
[
"myVC3",
"myVC4"
]
[
"myVC4"
]Manipulating nodes
Save a Node
Create a new node in vertexCollectionName:
graph.vertexCollectionName.save(data, options)
data(object): JSON data of node.options(object, optional): See the collection object
Examples
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
graph.male.save({name: "Floyd", _key: "floyd"}, { returnNew: true });Show output
{
"_id" : "male/floyd",
"_key" : "floyd",
"_rev" : "_kgUuVky---",
"new" : {
"_key" : "floyd",
"_id" : "male/floyd",
"_rev" : "_kgUuVky---",
"name" : "Floyd"
}
}Replace a Node
Replaces the data of a node in collection vertexCollectionName:
graph.vertexCollectionName.replace(vertexId, data, options)
vertexId(string):_idattribute of the nodedata(object): JSON data of node.options(object, optional): See the collection object
Examples
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
var doc = graph.male.save({neym: "Jon", _key: "john"});
graph.male.replace("male/john", {name: "John"}, { returnOld: true, returnNew: true });Show output
{
"_id" : "male/john",
"_key" : "john",
"_rev" : "_kgUuVmi--_",
"_oldRev" : "_kgUuVmi---",
"old" : {
"_key" : "john",
"_id" : "male/john",
"_rev" : "_kgUuVmi---",
"neym" : "Jon"
},
"new" : {
"_key" : "john",
"_id" : "male/john",
"_rev" : "_kgUuVmi--_",
"name" : "John"
}
}Update a Node
Updates the data of a node in collection vertexCollectionName.
graph.vertexCollectionName.update(vertexId, data, options)
vertexId(string):_idattribute of the nodedata(object): JSON data of node.options(object, optional): See the collection object
Examples
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
var doc = graph.female.save({name: "Lynda", _key: "linda"});
graph.female.update("female/linda", {name: "Linda", _key: "linda"}, { returnOld: true, returnNew: true });Show output
{
"_id" : "female/linda",
"_key" : "linda",
"_rev" : "_kgUuVom--A",
"_oldRev" : "_kgUuVom--_",
"old" : {
"_key" : "linda",
"_id" : "female/linda",
"_rev" : "_kgUuVom--_",
"name" : "Lynda"
},
"new" : {
"_key" : "linda",
"_id" : "female/linda",
"_rev" : "_kgUuVom--A",
"name" : "Linda"
}
}Remove a Node
Removes a node from a collection of the named graph. Additionally removes all incoming and outgoing edges of the node.
graph.vertexCollectionName.remove(vertexId, options)
vertexId(string):_idattribute of the nodeoptions(object, optional): See the collection object
Examples
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
var doc = graph.male.save({name: "Kermit", _key: "kermit"});
db._exists("male/kermit");
var success = graph.male.remove("male/kermit");
db._exists("male/kermit");Show output
true
falseManipulating Edges
Save a new Edge
Creates an edge from node data._from to node data._to in collection
edgeCollectionName.
graph.edgeCollectionName.save(data, options)
data(object): JSON data of the edge. Needs to include a_fromattribute with the document identifier of the source node and a_toattribute with the document identifier of the target node.options(object, optional): See the collection object
Examples
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
graph.relation.save({
_from: "male/bob",
_to: "female/alice",
_key: "bobAndAlice", type: "married" }, { returnNew: true });Show output
{
"_id" : "relation/bobAndAlice",
"_key" : "bobAndAlice",
"_rev" : "_kgUuVsW--A",
"new" : {
"_key" : "bobAndAlice",
"_id" : "relation/bobAndAlice",
"_from" : "male/bob",
"_to" : "female/alice",
"_rev" : "_kgUuVsW--A",
"type" : "married"
}
}If the collections of from and to are not defined in an edge definition
of the graph, the edge is not stored.
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
graph.relation.save(
"relation/aliceAndBob",
"female/alice",
{type: "married", _key: "bobAndAlice"});
Show output
[ArangoError 1906: invalid edge between relation/aliceAndBob and female/alice. Doesn't conform to any edge definition]Replace an Edge
Replaces the data of an edge in collection edgeCollectionName.
Note that _from and _to are mandatory.
graph.edgeCollectionName.replace(edgeId, data, options)
edgeId(string):_idattribute of the edgedata(object, optional): JSON data of the edgeoptions(object, optional): See the collection object
Examples
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
var doc = graph.relation.save("female/alice", "female/diana", {typo: "nose", _key: "aliceAndDiana"});
graph.relation.replace("relation/aliceAndDiana",
{ type: "knows", _from: "female/alice", _to: "female/diana" },
{ returnOld: true, returnNew: true });Show output
{
"_id" : "relation/aliceAndDiana",
"_key" : "aliceAndDiana",
"_rev" : "_kgUuVwG---",
"_oldRev" : "_kgUuVwC--B",
"old" : {
"_key" : "aliceAndDiana",
"_id" : "relation/aliceAndDiana",
"_from" : "female/alice",
"_to" : "female/diana",
"_rev" : "_kgUuVwC--B",
"typo" : "nose"
},
"new" : {
"_key" : "aliceAndDiana",
"_id" : "relation/aliceAndDiana",
"_from" : "female/alice",
"_to" : "female/diana",
"_rev" : "_kgUuVwG---",
"type" : "knows"
}
}Update an Edge
Updates the data of an edge in collection edgeCollectionName.
graph.edgeCollectionName.update(edgeId, data, options)
edgeId(string):_idattribute of the edgedata(object, optional): JSON data of the edgeoptions(object, optional): See the collection object
Examples
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
var doc = graph.relation.save("female/alice", "female/diana", {type: "knows", _key: "aliceAndDiana"});
graph.relation.update("relation/aliceAndDiana",
{ type: "quarreled", _key: "aliceAndDiana" },
{ returnOld: true, returnNew: true });Show output
{
"_id" : "relation/aliceAndDiana",
"_key" : "aliceAndDiana",
"_rev" : "_kgUuVyO--_",
"_oldRev" : "_kgUuVyO---",
"old" : {
"_key" : "aliceAndDiana",
"_id" : "relation/aliceAndDiana",
"_from" : "female/alice",
"_to" : "female/diana",
"_rev" : "_kgUuVyO---",
"type" : "knows"
},
"new" : {
"_key" : "aliceAndDiana",
"_id" : "relation/aliceAndDiana",
"_from" : "female/alice",
"_to" : "female/diana",
"_rev" : "_kgUuVyO--_",
"type" : "quarreled"
}
}Remove an Edge
Removes an edge from an edge collection of the named graph. Any other edges that directly reference this edge like a node are removed, too.
graph.edgeCollectionName.remove(edgeId, options)
edgeId(string):_idattribute of the edgeoptions(object, optional): See the collection object
Examples
var examples = require("@arangodb/graph-examples/example-graph");
var graph = examples.loadGraph("social");
var doc = graph.relation.save("female/alice", "female/diana", {_key: "aliceAndDiana"});
db._exists("relation/aliceAndDiana")
var success = graph.relation.remove("relation/aliceAndDiana")
db._exists("relation/aliceAndDiana")Show output
true
false