# neo4j-embedded

> The embedded Neo4j Graph Database for Node.js.

Latest version **0.3.2** (published 2013-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install neo4j-embedded
pnpm add neo4j-embedded
yarn add neo4j-embedded
bun add neo4j-embedded
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2013-09-11 |
| First published | 2013-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 37 |
| Author | Jochen Weis |
| Maintainers | joewhite86 |
| Keywords | neo4j, graph database, driver |

## Links

- npm: https://www.npmjs.com/package/neo4j-embedded
- Repository: http://github.com/joewhite86/node-neo4j-embedded
- Issues: http://github.com/joewhite86/node-neo4j-embedded/issues
- npm.io page: https://npm.io/package/neo4j-embedded

## Dependencies (1)

- [java](https://npm.io/package/java.md) joewhite86/node-java

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.3.2 (latest) — 2013-09-11
- 0.3.1 — 2013-08-08
- 0.3.0 — 2013-07-08
- 0.2.10 — 2013-07-01
- 0.2.9 — 2013-06-27
- 0.2.8 — 2013-06-26
- 0.2.7 — 2013-06-11
- 0.2.6 — 2013-06-06
- 0.2.5 — 2013-06-05
- 0.2.3 — 2013-05-15

## README

# node-neo4j-embedded

[![Build Status](https://travis-ci.org/joewhite86/node-neo4j-embedded.png?branch=master)](https://travis-ci.org/joewhite86/node-neo4j-embedded)

The embedded Neo4j Graph Database for Node.js.

## Installation

``` bash
npm install neo4j-embedded
```

## Documentation

API documentation can be found here: http://docs.whitefrog.de/neo4j-embedded

## Usage

Note that the Neo4j version is 1.9, so you need Java 7 on your machine for this to work.
If you want to change that, you need to edit the pom.xml and compile for yourself.

### Create a database

``` javascript
var neo4j = new require('neo4j-embedded');
neo4j.setVMOptions('-Xmx4096m');
neo4j.setDatabaseProperties({'org.neo4j.server.manage.console_engines': 'shell', 'org.neo4j.server.webserver.port', '7575'});

// default embedded
neo4j.connect('graph.db', function(err, database) {
  // do something
});
// enable REST and Webinterface
neo4j.connectWrapped('graph.db', function(err, database) {
  // do something
});
// connect to a high availability cluster
neo4j.connectHA('graph.db', function(err, database) {
  // do something
});
// connect to a high availability cluster, enabling REST and Webinterface
neo4j.connectHAWrapped('graph.db', function(err, database) {
  // do something
});
```

### Create nodes and relationships

``` javascript
var tx;
try {
  tx = database.beginTx();
  var homer = database.createNode();
  var marge = database.createNode();
  var married = homer.createRelationshipTo(marge, 'MARRIED_WITH');
  tx.success();
}
catch(e) {
  tx.failure();
}
finally {
  tx.finish(); 
}
```

### Delete nodes and relationships

``` javascript
var tx;
try {
  tx = database.beginTx();
  var homer = database.getNodeById(1);
  var married = homer.getRelationship('MARRIED_WITH');
  married.delete();
  homer.delete();
  tx.success();
}
catch(e) {
  tx.failure();
}
finally {
  tx.finish();
}
```

### Deal with properties

``` javascript
var tx;
try {
  tx = database.beginTx();
  var marge = database.getNodeById(2);
  marge.setProperty('name', 'Marge Simpson');
  marge.setProperty('haircolor', 'blue');
  var properties = marge.getProperties();
  // properties: {name: 'Marge Simpson', haircolor: 'blue'}
  var hairColor = marge.getProperty('haircolor');
  // hairColor: 'blue'
  tx.success();
}
catch(e) {
  tx.failure();
}
finally {
  tx.finish(); 
}
```

### Handle indices

``` javascript
var tx;
try {
  tx = database.beginTx();
  var marge = database.getNodeById(2);
  marge.index('SIMPSONS', 'name', marge.getProperty('name'));
  marge.removeFromIndex('SIMPSONS');
  tx.success();
}
catch(e) {
  tx.failure();
}
finally {
  tx.finish();
}
```

### Cypher queries

``` javascript
var query = 'START n=node({search}) RETURN n';
database.query(query, {search: 2}, function(err, results) {
  for(var i = 0; i < results.length; i++) {
    console.log(results[i].n.getId());
  }
});
```

### Query Builder

``` javascript
var query = database.queryBuilder();
query.startAt({n: 'node({search})'})
     .match('(n)-[:MARRIED_WITH]->()')
     .returns('n');

// disable counting
// query.dontCount(); -> total will be -1

query.execute({search: 1}, function(err, results, total) {
  for(var i = 0; i < results.length; i++) {
    console.log(results[i].n.getId());
  }
});
```

## Testing

``` bash
cd node-neo4j-embedded
npm install --dev
npm test
```

---
_Source: https://npm.io/package/neo4j-embedded · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
