Accessing Neo4j from Node.js
Node.js
is getting increasingly popular with the entrant of JavaScript on the server side due to its asynchronous nature.
In this recipe, we will learn how to access the Neo4j graph database using Node.js
.
Getting ready
Node-Neo4j is the most popular client when its comes to accessing the Neo4j graph database server from Node.js. For more information on this, you can refer to https://github.com/thingdom/node-neo4j.
The following steps will get you started with Node-Neo4j:
Node-Neo4j can be installed by typing the following on the command line:
npm install neo4j
In the Node.js code, include the library, which has been installed, using the following line of code:
var neo4j = require('neo4j');
How to do it…
The following steps will get you started with this recipe:
Let's access Neo4j from Node.js using the following code:
var neo4j = require('neo4j'); var db = new neo4j.GraphDatabase('http://localhost:7474');
Let's create the first node using the following code:
var node =...