gremlin - Why is hasId() only returning one of the ids in a list?
问题描述
I'm using javascript gremlin to get results based on a list of ids:
await g
.addV("test")
.property(id, "1")
.addV("test")
.property(id, "2")
.next();
const result = await g
.V()
.hasId("1","2")
.next()
result
only contains id 1:
{"value":{"id":"1","label":"test"},"done":false}
If I hop on the console, I get the expected result.
g.V().hasId("1","2")
==>v[1]
==>v[2]
Why is there a discrepancy between these results?
The JS is running in AWS Lambda on Node 10.x.
gremlin: 3.4.2
GraphSON v2
解决方案
您看到的这种差异是 Gremlin 控制台在遇到控制台时的工作方式的结果,Iterator
它会自动迭代所有答案。在 JS 中,您必须使用Iterator
命令。
使用Iterator.next()
时结果将是迭代器中的下一个值。如果你想获得我会使用的所有值toList
const result = await g
.V()
.hasId("1","2")
.toList()
推荐阅读
- python - 使用 Lambda 函数并在出现键错误的情况下继续
- powerbi - 连接是否使我的 power bi 服务从 excel 源文件导入数据是实时的
- reactjs - 如何处理在 API 调用响应上重新初始化的状态?
- android - 如何在 Android 上访问完整的 ClipboardManager 历史记录?
- java - 如何自动化系统服务?
- r - 如何从 ggplot2::geom_density_2d_filled 获取有关轮廓的信息?
- javascript - 如何在 Material UI X-Grid 中获取过滤后的行数?
- vba - 如何运行代码来自动化电子邮件模板?
- python-3.x - PyChram 上的第三方模块重新加载警告
- ios - 某些 UIView 属性上的 RxSwift `observeWeakly` 失败,而 `observe` 确实有效