2017-01-01 39 views
0

是否可以通过指定可能存在或不存在的文档创建边,并在它们不存在时创建它们?是否有可能在ArangoDB中同时创建边和顶点

举例来说,如果我喜欢运行一个查询:

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

如果其他任何文档/某事或文档/不存在,我会得到一个错误。有没有我可以通过的选项,如果它们不存在,会创建docs/something和docs/other(或许是空对象)?

注:我可以做一个批量导入,而不文件创建边缘- _TO和/或_from只是没有出路 - 但我宁愿创建一个空白文档

回答

1

一个管理图的特点是,它确保图形的完整性。因此使用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中,顶点集合必须先存在。

相关问题