npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

neo4j-js

v0.0.8

Published

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

Downloads

22

Readme

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.

To run the unit tests:

  • Copy test/config.sample.json to test/config.json and edit as necessary.
  • Go to the root neo4j-js directory and type mocha.