当 Cypher 查询为 MATCH 时,我在解析来自neo4j-go-driver 官方驱动程序的结果时遇到问题。使用 README.md 示例中的 CREATE 查询可以正常工作,但使用 MATCH 不会使用结果 Record().GetByIndex(0) 进行索引
result, err = session.Run("match(n) where n.id = 1 return n", map[string]interface{}{})
if err != nil {
panic(err)
}
for result.Next() {
a := result.Record().GetByIndex(1) //error: Index out or range
b := result.Record().GetByIndex(0).(int64) //error: interface {} is *neo4j.nodeValue, not int64
c := result.Record().GetByIndex(0) //prints corect result: &{14329224 [Item] map[id:1 name:Item 1]}
fmt.Println(c)
}
Run Code Online (Sandbox Code Playgroud)
由于 nodeValue 不是导出类型,我不知道对断言属性或整个接口返回 nodeValue 类型的热度。