如何连接到同一集合中的两个文档

How to connect to two document in the same collection

在 Arango DB 中,如何构建一个集合中文档的关系图?该文档涵盖了使用多个 table 集合,但没有介绍如何在一个集合中使用它。

如果我没理解错的话,要求是使用单个顶点集合创建一个图。

以下示例(ArangoShell 代码)使用名为 v 的单个顶点集合和名为 e 的边集合创建了一个名为 example 的图:

var g = require("org/arangodb/general-graph");
g._create("example", [ { collection: "e", "from": [ "v" ], "to" : [ "v" ] } ]);
g._graph("example");

这将显示此图形定义:

[ Graph example EdgeDefinitions: [ 
  "e: [v] -> [v]" 
] VertexCollections: [ ] ]

请注意,仍然需要单独的边集合,但顶点可以存储在单个集合(如上所示)或多个集合中。