pyArango-使用指定的_key创建边

时间:2019-04-19 12:30:46

标签: python graph arangodb pyarango

我在ArangoDB中有一个ActionResult。如何创建具有指定的graph值的边?我的代码:

_key

我可以看到edge_attributes = {"_key": "ab", "count": 0} graph.createEdge(collection_edges_name, node_from_id, node_to_id, edge_attributes) 以及count_from的适当值,但是_to是一些随机数。

如何创建具有特定_key的边?我想指定一个键,以便通过键快速查询边缘,并防止从节点A到节点B的多个边缘。

1 个答案:

答案 0 :(得分:0)

我为此问题准备了一种解决方法。我用指定的具有边的集合名称创建Edge类的实例,然后调用:

edge_attributes = {"_key": edge_key,
                   "_from": parent_id,
                   "_to": node_to_id,
                   "count": 0}
edge = my_edges_collection.createDocument(edge_attributes)
edge.save()

此解决方案创建具有正确密钥和ID的文档。