Skip to content

An npm package to spin up a Neo4j database from NodeJS code

Notifications You must be signed in to change notification settings

AhsanShihab/neo-on-demand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

neo-on-demand

version node

neo-on-demand creates neo4j (community edition) database instance from nodejs code. The database can be persistent or temporary, making it ideal to use for test setup. You can create multiple instances of neo4j database and run them in parallel. This is useful for parallel test running.

npm install --save-dev neo-on-demand

Neo4J

This package runs neo4j bin file natively on your machine. To run the bin file, you need to have Java installed. If you don't have java installed, install the version best suited for the neo4j version you intend to run. You can find the requirements in the neo4j doc

Supported neo4j version

Tested with version 3.5.0 and 4.x.x

Supported OS

Unix and Windows

Example

import NeoDB from 'neo-on-demand';

const main = async () => {
  const db = new NeoDB()
  await db.start()
  const httpUrl = db.getHttpURL()
  const boltUrl = db.getBoltURL()
  // do your stuff

  // then close the database
  db.stop()
}

You can pass the http and bolt port number and run multiple databases.

import NeoDB from 'neo-on-demand';

const main = async () => {
  const db1 = new NeoDB(7474, 7687)
  const db2 = new NeoDB(7475, 7688)
  ...
}

You can pass an option object as the third parameter which can have the following optional properties.

  • version (:string) - specify the version number of neo4j server
  • persistData (:boolean) - If true, data will be kept after closing the database. Default value is false

Troubleshoot

If the code fails to start the server, first make sure the server can start natively on your machine. To check that,

  • Go to <your user home directory>/.neo-on-demand/versions/neo4j-community-<version number>
  • open a terminal
  • run ./bin/neo console --verbose (or bin\neo.bat console --verbose on windows)
  • If the server is failing to run, check the log to see what is causing the issue.

If the server properly runs, please create an issue with all the details.

About

An npm package to spin up a Neo4j database from NodeJS code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published