• This repository has been archived on 20/Mar/2019
  • Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Node.js (pure JavaScript) client library for accessing neo4j databases with batch support.

DEPRECATION NOTICE

THIS LIBRARY IS DEPRECATED. It has not been updated in years, and will not be supported in any way. You should choose a different Neo4j library. This repository exists solely for historical purposes.

neo4j-js

A Node.js (pure JavaScript) client library for accessing neo4j databases with batch support.

Goals

  • Support as much (or all) of the REST API as possible.
  • Batch processing (both manual and through automatic shortcuts).
  • Have intuitive function "overloads" for usability.
  • Pure JavaScript without dependencies.

Rationale (or, why another Node.js library for neo4j?)

A Node.js client library already exists for neo4j: https://github.com/thingdom/node-neo4j. It has been around since 2011 and is likely a good choice for Node.js/neo4j projects which need a proven solution in the near future.

After looking at node-neo4j, I found a few things which prompted me to write my own library:

  • No batch support
  • Odd node creation syntax
  • Development seems to have stalled
  • Written in CoffeeScript (just a personal preference)

Current Status

Note: This library is in the early stages of development, is incomplete, and not by any means guaranteed to be stable. If you have input, or are interested in contributing to development or testing, please contact me! My email address is on my github account, or you can use the issue tracker.

A comprehensive checklist of which API methods have and have not been implemented so far is available in the Rest.md file.

All of the methods have only been tested on neo4j 1.8.2 so far. Backwards compatibility characteristics are unknown.

Cypher Queries

Cypher Queries with and without params are fully supported, however, nested results are not currently parsed for Node/Relationship/Path objects. In other words, nested results are returned raw.

Node and Relationship API Endpoints

Nearly all Node and Relationship endpoint features are implemented. See the Rest.md file for details.

Indexing

Indexing is partially implemented. Indexes can be created, deleted, listed, and queried. Key/value pairs can be inserted and removed from indexes using nodes and relationships. Automatic Indexing can be configured. Unique Indexing features are being worked on currently.

Graph Algorithms

The built in graph algorithms of shortest path and Dijkstra are supported through the REST API, but not yet through this library. It is, however, a priority and should be relatively easy.

Gremlin Plugin

Gremlin support has not been implemented yet. Priority is considered low since Cypher queries are available, and preferred in most cases.

Usage

The examples below are provided to help get you started, but are far from comprehensive. Reference Documentation is currently being worked on. Another place to look for examples in the meantime are the unit tests found inside the /test folder.

Install

npm install neo4j-js

Connecting

neo4j.connect('http://localhost:7474/db/data/', function (err, graph) {
    if (err)
        throw err;
        
    // do something with the graph
});

Creating Nodes

Graph.createNode reference

graph.createNode({ prop1: 'node property', boolProperty: false }, function (err, node) {
    console.log(err ? err : node);
});

Get Node By Id

Graph.getNode reference

graph.getNode(5, function (err, node) {
    console.log(err ? err : node.data); // print the node's properties
}

Get Multiple Nodes

Graph.getNode reference

graph.getNode([5, 23, 84], function (err, nodes) {
    if (err) {
        console.log(err)
        return;
    }
    
    for (var i in nodes)
        console.log(nodes[i].data);
}

Cypher Queries

See Graph.query for an example.

Batching

Most of the library functions optionally accept a Batch object as the first argument. This allows multiple API calls to be grouped into a single request which may significantly improve performance in some cases.

var batch = graph.createBatch();

//create a node and get another in the same request
graph.createNode(batch, { key: 'value' }, function (error, node) {
    //this will not be called until after batch.run()
});
graph.getNode(batch, 18, function (error, node) {
    //this will not be called until after batch.run()
});

batch.run();

Unit Testing

Some unit tests are in place, and more should follow as appropriate.

The unit tests rely on Mocha and Chai which are included as development dependencies in the npm package. If not installed already, go to the node_modules/neo4j directory and type npm install.

Use npm test to run the unit tests. If you need to connect to a host other than localhost:7474, create a test/config.json file using the same JSON format as the config.defaults.json in the same directory.

More Repositories

1

node-gc-profiler

Allows you to profile when the garbage collector runs, and how long it takes.
C++
191
star
2

Mayflower.NET

SQL Server Migrator
C#
47
star
3

PerformanceTypes

A collection of low (or zero) allocation algorithms for .NET
C#
25
star
4

vagrant-neo4j

A vagrant configuration to run Neo4j 2.0 in a VirtualBox.
Shell
7
star
5

tacoverflow

6
star
6

EnumToSql

A simple .NET console application which replicates C# enums to SQL Server
C#
5
star
7

node-bcp

Node.js utility for interacting with SQL Server Bulk Copy Program (bcp).
JavaScript
5
star
8

BitPacker

A simple binary serializer for .NET.
C#
5
star
9

tedium

A generator-based wrapper for Tedious to make it easier to work with
JavaScript
2
star
10

neo-debug

A more configurable debug utility module for Node.js.
JavaScript
1
star
11

Jadeite

Maybe someday it will be a C# templating engine
C#
1
star
12

idiot-check

A chrome extension to remind you when you're on production vs. local.
JavaScript
1
star
13

coback

Creates standard callbacks which have a yieldable component, allowing you to pass them as a traditional callback, but yield on them later.
JavaScript
1
star
14

oshi

A scripting-based process manager for node.js.
JavaScript
1
star
15

node-ubuntu-build

A simple Ubuntu Script to build and Install Node.js on Ubuntu
Shell
1
star
16

arguer

Normalizes arguments for JavaScript functions with optional arguments and provides optional typing.
JavaScript
1
star
17

koa-trail

A koa router which supports chained route matching.
JavaScript
1
star
18

flex-events

A powerful, flexible and highly customizable event system for JavaScript. Supports all browsers and Node.js.
JavaScript
1
star
19

StopwatchStruct

Value type implementation of the C# stopwatch.
C#
1
star