Most advanced, well documented and efficient REST client for Neo4j database, with 100% tests coverage. Fibers allows to give a new level experience to developers, no more callback-hell and blocking operations. Speed and low resources consumption is top priority of neo4j-fiber package.
- 100% tests coverage
- Version for Meteor.js - https://atmospherejs.com/ostrio/neo4jdriver
- This this library is heavily depends from Fibers, so you required to wrap all code into Fiber, see example
- This package uses batch operations to perform queries. Batch operations lets you execute multiple API calls through a single HTTP call. This improves performance for large insert and update operations significantly
- This package was tested and works like a charm with GrapheneDB
- To find more about how to use Cypher read Neo4j cheat sheet
Installation
npm install --save neo4j-fiber
Demo Apps
- Hosted at Heroku (GrapheneDB Add-on)
- Check out it's source code
API:
Please see full API with examples in our wiki
Basic Usage Examples
Connect to Neo4j
const Neo4jDB = Neo4jDB;const db = 'http://localhost:7474' username: 'neo4j' password: '1234';
Set connection URL via environment variables
Set NEO4J_URL
or GRAPHENEDB_URL
to as connection URL to Neo4j Database
NEO4J_URL="http://neo4j:1234@localhost:7474" node index.js
If environment variable is set, no need to pass url
argument into Neo4jDB
constructor
const Neo4jDB = Neo4jDB;const db = ;
Run simple query
const cursor = db; console;// Returns array of nodes:// [{// n: {// long: -75.683333,// lat: 45.416667,// title: "Ottawa",// id: 8421,// labels": ["City"],// metadata: {// id: 8421,// labels": ["City"]// }// }// }] // Iterate through results as plain objects:cursor; // Iterate through cursor as `Neo4jNode` instances:cursor;
Create node
const node = db;const node2 = db;
Get node by id
const node = db;
Delete node
node;
Create relationship
const n1 = db;const relationship = db;
Delete relationship
relationship;
Cities example
// Create some data:const cities = {};cities'Zürich' = dblabel'City'; cities'Tokyo' = dblabel'City'; cities'Athens' = dblabel'City'; cities'Cape Town' = dblabel'City'; // Add relationship between cities// At this example we set distancecities'Zürich';cities'Tokyo'; // Create route 1 (Zürich -> Athens -> Cape Town -> Tokyo)cities'Zürich';cities'Athens';cities'Cape Town'; // Create route 2 (Zürich -> Cape Town -> Tokyo)cities'Zürich';cities'Cape Town'; // Create route 3 (Zürich -> Athens -> Tokyo)cities'Zürich';cities'Athens'; // Get Shortest Route (in km) between two Cities:const shortest = cities'Zürich'0;let shortestStr = 'Shortest from Zürich to Tokyo, via: ';shortestnodes; shortestStr += '| Distance: ' + shortestweight + ' km';console; // <-- Shortest from Zürich to Tokyo, via: Zürich, Cape Town, Tokyo, | Distance: 11122.82 km // Get Cheapest Route (in notional currency) between two Cities:const cheapest = cities'Zürich'0;let cheapestStr = 'Cheapest from Zürich to Tokyo, via: ';cheapestnodes; cheapestStr += '| Price: ' + cheapestweight + ' nc';console; // <-- Cheapest from Zürich to Tokyo, via: Zürich, Athens, Tokyo, | Price: 900 nc
For more complex examples and docs, please see our wiki