我是Neo4J的新手。到目前为止,我成功地安装并启动了Neo4J服务器,并通过运行命令neo4j status对其进行了检查。
通过使用node-ne4j驱动程序向数据库添加和更新节点。
在我的nodejs服务器中,我创建了一个新数据库:
db = new neo4j("http://127.0.0.1:7474");接下来,我插入一个新节点:
db.insertNode( {"name": "Darth Vader","sex": "male"}, (err, node) ->
if err then throw err
console.log "Insert node"
console.log node
)在插入新节点时,我没有遇到任何错误。但是,当我尝试读取此节点时
db.readNode( {"name": "Darth Vader"}, (err, node) ->
if err then throw err; # 48th line of server.js
console.log "Read node"
console.log node
)ReadNode函数在第48行抛出以下异常(您可以在上面给出的代码片段中找到第48行)。
server.js:48
throw err;
^
Error: HTTP Error 500 occurred while reading a node.
at node_modules/node-neo4j/main.js:151:15
at Request.callback (node_modules/node-neo4j/node_modules/superagent/lib/node/index.js:656:3)
at Request.<anonymous> (node_modules/node-neo4j/node_modules/superagent/lib/node/index.js:131:10)
at Request.emit (events.js:95:17)
at IncomingMessage.<anonymous> (node_modules/node-neo4j/node_modules/superagent/lib/node/index.js:802:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:929:16
at process._tickCallback (node.js:419:13)然后,我尝试通过检查我的数据库来调试我的进程,并尝试neo4j-shell并在命令行中输入dbinfo,我希望看到我的数据库和已经插入的Darth Vader节点。
但是,dbinfo根本不返回任何内容!
如何使用ne4j-shell查找我的数据库和此数据库中的节点?
如何确保已成功插入节点?如何读取我已经插入的节点?
你有什么想法吗?
提前谢谢你!
发布于 2014-08-27 17:26:16
为了说明这一点:有两个node-ne4j版本:
https://github.com/philippkueng/node-neo4j
https://github.com/thingdom/node-neo4j
您正在使用philippkueng版本:db.readNode将仅与nodeId一起工作。我认为在查询neo4j数据库时,应该使用带有cypher语句的db.cypherQuery()。
例如:
db.cypherQuery('MATCH (n {name: "Darth Vader"}) RETURN n',
function(err, result){
if(err) throw err;
console.log(result.data); // delivers an array of query results
console.log(result.columns); // delivers an array of names of objects getting returned
});如果您想使用不带Cypher的标签和索引来查找节点,您可以使用以下命令:
// add Darth Vader with the label Person
db.insertNode( {name: 'Darth Vader',sex: 'male'}, 'Person',
function(err, node) {})
db.readNodesWithLabelsAndProperties('Person', {name: 'Darth Vader'},
function (err, result) {})要进行调试,请使用Neo4j浏览器,网址为:
http://localhost:7474https://stackoverflow.com/questions/25515455
复制相似问题