【问题标题】:Is it possible to create edges and vertexes simultaneously in ArangoDB是否可以在 ArangoDB 中同时创建边和顶点
【发布时间】:2017-01-01 01:57:32
【问题描述】:

是否可以通过指定可能存在或可能不存在的文档来创建边缘,并在它们不存在时创建它们?

例如,如果我运行如下查询:

INSERT {_to: 'docs/something', _from: 'docs/other'} IN edges

如果 docs/something 或 docs/other 不存在,我会收到错误消息。如果它们不存在,我是否可以传递一个选项来创建 docs/something 和 docs/other(可能是一个空对象)?

注意:我可以进行批量导入并创建边没有文档 - _to 和/或 _from 只会导致无处可去 - 但我宁愿创建一个空白文档

【问题讨论】:

    标签: database arangodb aql


    【解决方案1】:

    Managed Graphs 的一个特点是,它确保了图形的完整性。因此使用the edge management facility 将在ArangoDB 中结束,不允许插入悬垂边。

    但是,ArangoDBs 图形功能是在文档功能之上分层的。文档功能不保证图形完整性;因此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,顶点集合必须首先存在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多