0.5.0 • Published 10 years ago

neo4j-loader v0.5.0

Weekly downloads
2
License
-
Repository
github
Last release
10 years ago

A simple Node module to quickly load smalller datasets into Neo4j for analysis in the their browser application.

Dependencies:

  • Async.js
  • Request.js

Installation

npm install neo4j-loader

API

There are only three methods to the API (fromFile, setURL, addToQueue), so it is very easy to use. Basically, you can use it to load data from a JSON file or in the context of a larger script - sending each realtionship to the queue manually.

Loading from a JSON file

var fs = require('fs');
var loader = require("neo4j-loader");

var inputFile = 'data/relationships.json';
var dataURL = 'http://localhost:7474/db/data/';

loader.fromFile(inputFile, dataURL);

Add Each to Queue Manually

var fs = require('fs');
var loader = require("neo4j-loader");

var inputFile = 'data/relationships.json';
var dataURL = 'http://localhost:7474/db/data/';

// Make sure you set the URL first.
loader.setURL(dataURL); 

fs.readFile(inputFile, 'utf-8', function (err, data) {
  if (err) throw err;
  var relations = JSON.parse(data);
  relations.forEach(function (relation) {
      loader.addToQueue(relation);
  });
});