gpt4 book ai didi

node.js - Neo4j Rest api 唯一性不起作用?

转载 作者:太空宇宙 更新时间:2023-11-04 01:11:32 25 4
gpt4 key购买 nike

我正在尝试在 Neo4j 中创建一个唯一的 Node ,但无法使其工作。

Node 代码:

var node = db.createNode({sampleDataKey: "sampleDataValue"});

node.save(function (err, user) {

node.index('user', 'indexValue', 'indexValue', function (err) {
if (err) console.log(err);
console.log(user.id);
});
});

我正在使用这个 Node 模块:https://github.com/thingdom/node-neo4j

我已经从 neo4j 库修改了 Node.js。至:

else {

var urlToPost = ((("" + services.node_index) + "/") + index + '?uniqueness=create_or_fail');
console.log(urlToPost);
console.log(key + ':' + value);

/* 123 */ return __this._request.post({
/* 124 */ url: urlToPost,

/* 125 */ json: {
/* 126 */ key: key,
/* 127 */ value: value,
/* 128 */ uri: __this.self
}
}, __cb(_, __frame, 17, 21, function ___(__0, __4) {
/* 123 */ response = __4;
console.log('response');
__then();
}, true));
}

每次我执行代码时都会创建一个新的新 Node ,但之后会出现错误。 ...这是两次执行的控制台日志:

30 May 16:51:24 - [nodemon] starting `node app.js`
Express server listening on port 3000
http://localhost:7474/db/data/index/node/user?uniqueness=create_or_fail
indexValue:indexValue
response
338
30 May 16:55:38 - [nodemon] restarting due to changes...
30 May 16:55:38 - [nodemon] /Users/nikolaialeksandrenko/Documents/work/noject/app.js


30 May 16:55:38 - [nodemon] starting `node app.js`
Express server listening on port 3000
http://localhost:7474/db/data/index/node/user?uniqueness=create_or_fail
indexValue:indexValue
response
339

最佳答案

问题出在我使用的版本(1.8.2)可选的“?uniqueness = create_or_fail”在 neo4j 1.9 中工作得很好。我唯一需要做的就是更新到新版本。

关于node.js - Neo4j Rest api 唯一性不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16838177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com