Neo Maggoo
Neo4j OGM for Node.js using proxified ES6 classes
WARNING: This package is still in an experimental state, currently in active development and could change at any time.
Installation
npm install neo-maggoo --save
Requirements
- Node.js >= 6.0.0
- Neo4j >= 3.0.0
Docs
https://bram-l.github.io/neo-maggoo/
Examples
const Node Relationship DB = // Node definition static get return relatives: Model: Person type: 'is_related_to' direction: RelationshipOUT father: Model: Person type: 'is_father_of' direction: RelationshipIN singular: true // Returns a single node instead of an array mother: Model: Person type: 'is_mother_of' direction: RelationshipIN singular: true // Returns a single node instead of an array // Initialize database connectionDB
READ
Get all nodes
const people = await Personall
Get a single node
// Find by UUIDconst person = await Person
// Find by Neo4j ID (NOTE: this may change over time)const person = await Person
Find nodes using filter
const people = await Person
const people = await Person
Find with related nodes
const foo = await Person
const foo = await Person
const foo = await Person
const foo = await Person
Find nodes using query
const people = await Person
Count nodes
const total = await Person
const total = await Person
const total = await Person
WRITE
Save an entire graph
const foo = await Personfoofathername = 'baz'await foo // Will save foo.father
Save nested nodes
const foo = const bar = foorelativesawait foo // Saves foo & bar, and creates a 'is_related_to' relationship
Delete collection
const people = await Personallawait people
Delete an entire graph
const foo = await Personawait foo // Deletes foo and its related nodes