在 ArangoDB 手册中,在运行时修改图形定义一节中,显示了以下在运行时修改边定义的方法:
向现有图添加新的边定义:
/* load graph module */
var graph_module = require("org/arangodb/general-graph");
/* load existing graph by name */
var graph = graph_module._graph("myGraph");
/* add a relation for edge collection myEC2, with vertices
between collections myVC1 and myVC3 */
var defs = graph_module._relation("myEC2", ["myVC1"], ["myVC3"]);
/* update the existing graph's definition */
graph._extendEdgeDefinitions(defs);
修改现有图中的现有边定义:
/* load graph module */
var graph_module = require("org/arangodb/general-graph");
/* load existing graph by name */
var graph = graph_module._graph("myGraph");
/* update the relation for edge collection myEC2, with vertices
between collections myVC23 and [ myVC42, myVC99 ] */
var defs = graph_module._relation("myEC2", ["myVC23"], ["myVC42", "myVC99"]);
/* update the existing graph's definition */
graph._editEdgeDefinitions(defs);