I'm new to Neo4J. So far, I successfully installed and started the Neo4J server and I checked it by running the command neo4j status
.
By using node-neo4j driver to add & update nodes to the database.
In my nodejs server, I create a new database:
db = new neo4j("http://127.0.0.1:7474");
Next, I insert a new node:
db.insertNode( {"name": "Darth Vader","sex": "male"}, (err, node) ->
if err then throw err
console.log "Insert node"
console.log node
)
I face no error when inserting a new node. However, when I try to read this 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 function throws the following exception at 48th line( you can find the 48th line at the code snippet given above).
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)
Then, I tried to debug my process by checking my database and tried neo4j-shell
and typed dbinfo
on the command line, I expected to see my database and the Darth Vader node that already inserted.
However, dbinfo
returns nothing at all!
How can I find my databases, and nodes in this database with neo4j-shell?
How can I make sure that I successfully inserted the node? How can I read the node that I already inserted?
Do you have any idea?
Thank you in advance!
To make things clear: There are two node-neo4j version out there:
https://github.com/philippkueng/node-neo4j
https://github.com/thingdom/node-neo4j
You are using the philippkueng version:
db.readNode
will work with nodeId's only. I think you should usedb.cypherQuery()
with a cypher statement instead for querying the neo4j database.For example:
Is you want to use labels and indexes without Cypher to lookup the node you could use this:
For debugging as @codewithcheese already mentions use the Neo4j browser at: