python - pyArango - 使用指定的 _key 创建边缘
问题描述
我graph
在 ArangoDB 中有一个。如何创建具有指定_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 的文档。
推荐阅读
- pandas - Pandas:转置 DataFrame 和 Series 的方法?
- python - 层顺序的输入 0 与层不兼容:输入形状的预期轴 -1 具有值 6,但接收到形状为 (None, 1) 的输入
- spring - Swagger UI 不使用 Spring Boot 在 POST 中生成 JSON 参数
- matlab - 最小值矩阵 A 在第 2 到第 3 行和第 2 列的索引行和索引列
- tensorflow - StarGAN 如何测试判别器
- python - 如何替换句子中的一组字符串
- typescript - WebStorm 不建议 TypeScript 中的图标名称
- c# - Automapper 双向复杂映射
- javascript - mscdex/node-ftp - 过早地等待 Promise Resolving
- python-3.x - 无法在 Streamlit 应用程序的同一页面中保留多个表单的输出