用指定的\u键创建边

2024-04-19 15:14:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我在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的多个边


Tags: tokey代码fromidnode节点ab
1条回答
网友
1楼 · 发布于 2024-04-19 15:14:55

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

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

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

相关问题 更多 >