Neode - Object Graph Mapper for Node JS

(Adam Cowley) #1

Neode is a Neo4j OGM for Node JS designed to take care of the CRUD boilerplate involved with setting up a neo4j project. The idea is to reduce the amount of code it takes to start a Neo4j project in with node. Just set up your models, create a Neode instance in your project and off you go...

I wrote an article on Medium explaining my inspiration and how to get started.

If you have any problems or have feedback, feel free to reply here or open up an issue. Pull Requests are also more than welcome.

Main Repository:
Example Project:

Happy coding!

(Benfluleck) #2

Hi @adam.cowley I was wondering if you have any examples of your OGM creating relationships between 2 nodes. I have been trying to see if I can use your OGM to achieve this without having to write a cypher.


(Adam Cowley) #3

Hi Ben,

At the moment you would need to do something like the following. It's not ideal but this assumes that you need to load the two nodes.

const person1 = neode.find('Person', id1);
const person2 = neode.find('Person', id2);

person1.relateTo(person2, rel_type, properties)
  .then(rel => console.log(

Or if you don't have the nodes loaded, you could pass through the information into a merge call:

neode.merge('Person', {
  id: 1,
  knows: [ {id: 2} ]

Let me know if that helps.

(Benfluleck) #4

so using knows as the relationship or would we have to explicitly define this in the Model.

module.exports: {
...knows : {

I would definitely be interested in using both methods but at the moment I am just getting to grips to define the relationships. I will let you know how I get on thanks

(Adam Cowley) #5

Knows would need to be defined in both scenarios. What are you trying to do? It would be easier to advise if I know what you're trying to do.

(Benfluleck) #6

Might as well thanks for the help :) . I am trying to construct a test project, it's a population management system. In the system, you define parent locations and any subsequent child locations defined are nested in their parents. And so on.

I defined the model as

module.exports = {
labels: ["Location"],

name: {
type: 'string',
unique: 'true', // Creates a Unique Constraint

id: {
primary: true,
type: 'uuid',
required: true, // Creates an Exists Constraint in Enterprise mode
malePopulation: {
type: 'number',
femalePopulation: {
type: 'number',
totalPopulation: {
type: 'number',
located_in: {
type: "relationship",
target: "Location",
relationship: "LOCATED",
direction: "in",
properties: {
name: "string"

I am using a Neo4j DB on GrapheneDB. At the moment I have only been able to create the nodes but no relationships. The final aim is to be able to update a child location and for those changes to reflect in the parents e.g. If I had a parent Location called U.S.A with a child New York which also had a child Maine. Updates in Maine and New York would reflect in U.S.A. Thanks for the help

(Benfluleck) #7

Aren't person1 and person2 Promises? Shouldn't it be:

  (res) => {
    res.relateTo(location2, 'located_in')
      .then(rel => console.log(