是否可以在 ArangoDB 中同时创建边和顶点
Is it possible to create edges and vertexes simultaneously in ArangoDB
是否可以通过指定可能存在或可能不存在的文档来创建边缘,并在它们不存在时创建它们?
例如,如果我 运行 查询如下:
INSERT {_to: 'docs/something', _from: 'docs/other'} IN edges
如果 docs/something 或 docs/other 不存在,我将得到一个错误。如果 docs/something 和 docs/other(可能是一个空对象)不存在,我可以通过一个选项吗?
注意:我可以进行批量导入并创建边缘 而无需 文档 - _to and/or _from 只会导致无处可去 - 但我宁愿创建一个空白文档
Managed Graphs 的一个特点是,它确保了图的完整性。因此,使用 the edge management facility 将导致 ArangoDB 不允许插入悬挂边。
但是,ArangoDB 的图形功能位于文档功能之上。文档功能不保证图形完整性;因此 inserting edges referencing non existant vertices is possible this way 如果边缘集合存在,您的示例查询将起作用。
然而,quoting the insert documentation:
Each INSERT operation is restricted to a single collection,
and the collection name must not be dynamic.
Only a single INSERT statement per collection is allowed per AQL query,
and it cannot be followed by read operations that access
the same collection, by traversal operations,
or AQL functions that can read documents.
因此您将无法在同一个查询中使用 AQL 动态创建顶点。
对于 ArangoDB 2.8,顶点集合必须首先存在。
是否可以通过指定可能存在或可能不存在的文档来创建边缘,并在它们不存在时创建它们?
例如,如果我 运行 查询如下:
INSERT {_to: 'docs/something', _from: 'docs/other'} IN edges
如果 docs/something 或 docs/other 不存在,我将得到一个错误。如果 docs/something 和 docs/other(可能是一个空对象)不存在,我可以通过一个选项吗?
注意:我可以进行批量导入并创建边缘 而无需 文档 - _to and/or _from 只会导致无处可去 - 但我宁愿创建一个空白文档
Managed Graphs 的一个特点是,它确保了图的完整性。因此,使用 the edge management facility 将导致 ArangoDB 不允许插入悬挂边。
但是,ArangoDB 的图形功能位于文档功能之上。文档功能不保证图形完整性;因此 inserting edges referencing non existant vertices is possible this way 如果边缘集合存在,您的示例查询将起作用。
然而,quoting the insert documentation:
Each INSERT operation is restricted to a single collection,
and the collection name must not be dynamic.
Only a single INSERT statement per collection is allowed per AQL query,
and it cannot be followed by read operations that access
the same collection, by traversal operations,
or AQL functions that can read documents.
因此您将无法在同一个查询中使用 AQL 动态创建顶点。
对于 ArangoDB 2.8,顶点集合必须首先存在。