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-bulk

v0.1.3

Published

A helper library to set up bulk data inserts for Neo4j databases

Downloads

29

Readme

node-neo4j-bulk Build Status Dependencies Code Climate

A helper library to set up bulk data inserts for Neo4j databases

The main goal of the neo4j-bulk library is to create an easy and intuitive way of setting up the data model for the neo4j bulk API so to set up an initial database state for test suites.

Usage

First, install neo4j-bulk as a development dependency:

npm install --save-dev neo4j-bulk

Then, in your pre-test setup script create a Bulk instance and add data. In this example I'll set up a graph representing the relational status between two purely fictional *cough* *cough* people:

var Bulk = require('neo4j-bulk');

var bulk = new Bulk();

var thomas = bulk.addNode({
	name: 'Thomas Vervest'
});

var annemarie = bulk.addNode({
	name: 'Annemarie Jellema'
});

bulk.addLabel('Male', thomas);
bulk.addLabel('Male', annemarie);

bulk.addRelation(thomas, annemarie, 'ENGAGED_TO');
bulk.addRelation(annemarie, thomas, 'ENGAGED_TO');

var batchObject = bulk.generateBatch();

The batchObject variable now contains an array which, when represented as JSON, can be posted to the Neo4j batch API resulting in the following psuedo-cypher dataset:

(t:Male { name: "Thomas Vervest" }),
(a:Female { name: "Annemarie Jellema" }),
(t)-[:ENGAGED_TO]->(a),
(a)-[:ENGAGED_TO]->(t)

Interface


Constructor - Bulk()

Returns a new instance of the neo4j-bulk class.


addNode(data)

Creates a new node and returns the node's reference ID.

Parameters

data (object): An object containing the node's properties

Returns

The newly created node's reference ID


addLabel(label[, nodeID])

Adds the label to the specified node, multiple labels can be added to a single node by calling this method multiple times.

Parameters

label (string): The name of the label nodeID (number, optional): The reference ID of a previously generated node, by default the last created node reference ID is used

Returns

Has no return value. An error is thrown if the reference ID is not an existing node, or no nodes have been created.


addRelation(startNode, endNode, relationName[, data])

Adds a named relationship between two nodes, starting at startNode and pointing to endNode. Optionally, the relation can be given properties using the data parameter.

Parameters

startNode (number): The reference ID of a previously generated node, from which the relationship will point endNode (number): The reference ID of a previously generated node, to which the relationship will point relationName (string): The name of the relationship data (object, optional): The properties of the relationship

Returns

Has no return value. An error is thrown if the startNode or endNode reference ID is not an existing node, or no nodes have been created.


branch()

Using this method a batch operation can be duplicated. This can be useful when a centralized dataset is used which is then extended per test case. Using this method the core dataset will remain unaltered.

Returns

A copy of the Batch instance.


generateBatch()

Generates a batch operation object, compatible with the Neo4j batch API when serialised to JSON.

Returns

An array containing the batch operations.


findNodeID(predicate)

Searches the collection of nodes for a node matching the predicate, and then returns the matching node's reference ID.

Parameters

predicate (function): The predicate function used to test a match. The function will take a single argument, which is the iterated node, and should return true if the predicate matches, or false otherwise.

Returns

The reference ID of the first node that matches the predicate, false otherwise.