【问题标题】:Amazon Neptune: Node PropertiesAmazon Neptune:节点属性
【发布时间】:2019-05-27 01:35:50
【问题描述】:

我已经运行了 gremlin 查询并获得了结果,但无法获得每个顶点属性。

这是我运行的查询:

g.V('a6b575a5-e2d3-334d-aa0b-5aa372d71fc0').outE('member').inV().unfold().toList()

这里是结果属性未定义如何获取?

2019-05-27T01:21:51.292Z    9f82a2ab-4271-406c-9601-0479899ccb61    [ Vertex {
id: '2cb575ab-d398-8a18-4c8c-4d5f6cca6076',
label: 'tribe',
properties: undefined },
Vertex {
id: '5eb575ad-59e5-0878-3d05-297c390b0479',
label: 'tribe',
properties: undefined } ]

【问题讨论】:

    标签: amazon-web-services gremlin amazon-neptune


    【解决方案1】:

    您应该在查询末尾添加 valueMap 步骤。

    g.V('a6b575a5-e2d3-334d-aa0b-5aa372d71fc0').outE('member').inV().valueMap(true).toList()
    
    

    【讨论】:

    • 如果您不需要边缘的值,您可以将查询简化为:g.V('a6b575a5-e2d3-334d-aa0b-5aa372d71fc0').out('member').valueMap(true).toList()
    【解决方案2】:

    您可以使用以下工作代码(Async/await 节点代码)

      const data = await g.V().toList();
      for (const v of data) {
        const _properties = await g.V(v.id).properties().toList();
        console.log(`${v.id} - ${v.label} - ${_properties}`);
      }
    

    【讨论】:

      猜你喜欢
      • 2023-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多