我希望有人能帮助我找出为什么对关系属性的批量更新在给定的数据集上不起作用。数据集中的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);
});我没有得到错误,它落入成功函数,但没有属性实际更新。
发布于 2019-04-18 07:55:53
当使用官方的neo4j Javascript驱动程序时,您应该使用neo4j.int()函数来包装通过参数传递的整数值,以解决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)}
];https://stackoverflow.com/questions/55736384
复制相似问题