我在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的多个边缘。
答案 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的文档。