0

I need help in order to update relation at runtime.

I have this use case:

I have created a graph with the following collections: - A (VertexCollection) - B (VertexCollection) - E (EdgeCollection) with relation( A -> B)

at runtme, using Foxx app, I neet to create a new collection (VertexCollection C) and I need to update EdgeCollection with the following relation( A -> [B,C]).

Is there a way to update relation at runtime?

Thanks in advanced, Peter

4

2 回答 2

2

您使用 Foxx 创建新系列

var db = require("internal").db;
var C = db._create("C");

边集合 E 可以包含任意顶点集合中的边,您可以在 E 中创建一条新边:

var edge = E.insert("A/xyz", "C/abc", {"someData":12});

例如,从 A 中带有 _key "xyz" 的顶点到 C 中带有 _key "abc" 的顶点创建一条边。

这回答了你的问题了吗?

于 2015-12-30T15:50:56.740 回答
2

在 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);
于 2016-01-04T18:55:06.263 回答