[英]pyArango - create edge with specified _key
我在ArangoDB中有一个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
是一些随机数。
如何使用特定的_key
创建边缘? 我想指定按键快速查询边缘的键,以及防止从节点A到节点B的多个边缘。
我为这个问题准备了一个解决方法。 我创建了一个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创建文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.