This package provides helper functions when using a neo4j database. Specifically when using JSON objects.

Usage no npm install needed!

<script type="module">
  import servitechNeo4jHelpers from 'https://cdn.skypack.dev/@servitech/neo4j-helpers';


Neo4j Helpers

This package provides helper functions when using a neo4j database to save time and to prevent repeating a bunch of code. It is especially useful if you have data in JSON format.


# with npm 
npm install @servitech/neo4j-helpers --save


Require the package, then configure with configureDb() using your database details. (see configureDb() function below for more information)

const neocon = require('@servitech/neo4j-helpers');
neocon.configureDb(process.env.NEO4J_HOST, process.env.NEO4J_USER, process.env.NEO4J_PASSWORD, {disableLosslessIntegers: true});


  • configureDb() - configureDb(host, username, password, options) - Configure your neo4j driver by passing the host server string (bolt://myNeo4j:7687), username, password, and optionally pass an object with neo4j.driver config options, for example: {disableLosslessIntegers: true}. This function instantiates the neo4j driver with these details.

  • executeCypher() - executeCypher(query, param) - Returns Promise. This function instantiates the neo4j connection and accepts a query to run. Resolves with result, or rejects with an error. Optionally set params for your custom cypher query in object format. (params replaces need for jsonToCypherForAddOrUpdate method).

  • jsonToCypherForAddOrUpdate() - DEPRECATED.

  • saveNode() - saveNode(nodeName, jsonIn) - Saves stringified json objects to database. Replaces jsonToCypherForAddOrUpdate().

  • parseObject() - parseObject(jsonIn) - Loops through the top level of a JSON object and parses any string that starts with [ or { into an object.