Neo4j Cypher关系批量更新属性

Neo4j Cypher关系批量更新属性,neo4j,cypher,neo4j-driver,neo4j-javascript,Neo4j,Cypher,Neo4j Driver,Neo4j Javascript,我希望有人能帮我弄清楚为什么在给定的数据集上对关系属性的批量更新不起作用。数据集中的id值是关系的neo4j idtq、rpc和weight是它的属性 var batchUpdate = [{"id":281,"tq":8,"rpc":2.4,"weight":84},{"id":283,"tq":5,"rpc":1.25,"weight":10}, {"id":286,"tq":4,"rpc":3.2,"weight":5}]; var nQuery = WITH {batchUpdate}

我希望有人能帮我弄清楚为什么在给定的数据集上对关系属性的批量更新不起作用。数据集中的id值是关系的neo4j id
tq
rpc
weight
是它的属性

var batchUpdate = [{"id":281,"tq":8,"rpc":2.4,"weight":84},{"id":283,"tq":5,"rpc":1.25,"weight":10},
{"id":286,"tq":4,"rpc":3.2,"weight":5}];

var nQuery = WITH {batchUpdate} AS stats UNWIND stats AS s MATCH ()-[k:BELONGS_TO]-() WHERE id(k)=s.id SET k.weight=s.weight, k.rpc=s.rpc, k.tq=s.tq;

session
.run(nQuery,{batchUpdate:batchUpdate})
.then(function (result) {
console.log('updated');
})
.catch(function (error) {
console.log('neo4j stats update error ' + error);
});

我没有收到任何错误,它属于success函数,但实际上没有更新任何属性。

当使用官方的neo4j Javascript驱动程序时,您应该使用该函数包装通过参数传递的整数值,以解决Javascript不支持64位整数的问题(而neo4j正是使用该函数)。默认情况下,Javascript驱动程序将参数中的整数转换为浮点数

浮点数将不被视为等于等效整数

尝试更改阵列,如下所示:

var neo4j = require('neo4j-driver').v1;

...

var batchUpdate = [
  {"id":neo4j.int(281),"tq":neo4j.int(8),"rpc":2.4, "weight":neo4j.int(84)},
  {"id":neo4j.int(283),"tq":neo4j.int(5),"rpc":1.25,"weight":neo4j.int(10)},
  {"id":neo4j.int(286),"tq":neo4j.int(4),"rpc":3.2, "weight":neo4j.int(5)}
];

哇,回答得很好。工作得很好!谢谢:)太好了!。记住对你的一个问题最好的答案。