1

我正在使用 Redisgraph。我正在使用这个查询:

MERGE (p:Person { age: 0 } )
RETURN p

但我得到的是age: ""

如果我查询:

MERGE (p:Person { age: 12 } )
RETURN p

这正确存储age: 12(不带引号)。

如何存储 0 的数值?谢谢!

4

1 回答 1

2

一个最小的例子,它创建一个属性值为 0 的节点并使用 redisgraph.js 检索它

const RedisGraph = require("redisgraph.js").Graph;
let graph = new RedisGraph("G");

(async () =>{
        await graph.query("CREATE (:L {v:0})");
        let res = await graph.query("MATCH (a) RETURN a, a.v");
        while (res.hasNext()) {
            let record = res.next();
            console.log(record.get("a"));
            console.log(record.get("a.v"));
        }

        graph.deleteGraph();
        graph.close();
    
    })();

输出:

Node { id: 1, label: undefined, properties: { v: 0 } }
0 

@albertoSpinella 你介意分享一个可重现的片段吗?

于 2022-02-07T07:11:46.953 回答