2013-05-30 51 views
1

我試圖在neo4j中創建一個獨特的節點,但無法使其工作。neo4j rest api獨特性不起作用?

節點代碼:

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); 
    }); 
}); 

我使用這個節點模塊:https://github.com/thingdom/node-neo4j

我從Neo4j的LIB修改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)); 
           } 

每次我執行代碼創建一個新的新節點,但在那之後錯誤。 ... 這裏是控制檯日誌2個處決:「獨特性= create_or_fail」

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 
+0

嗨Aleksandrenko你的意思是它的作品第一次,但不是第二次或以後? – tgkprog

+0

是的。第一次作品正確,之後它不... – Aleksandrenko

+0

好吧我不確定只是試圖澄清。當你說它第一次工作時 - >你能看到數據庫中的對象鍵 - >它是隨機還是相同的樣本值? – tgkprog

回答

1

的問題是從我所用的版本(1.8.2)的可選 工作只是在Neo4j的1.9罰款。我唯一需要做的就是更新到新版本。