# Neode - Object Graph Mapper for Node JS

**URL:** <https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524>\
**Category:** Projects & Collaboration\
**Created:** [August 27, 2018, 5:41pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524 "2018-08-27T17:41:29Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [August 27, 2018, 5:41pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/1 "2018-08-27T17:41:29Z")

</div>

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](https://medium.com/neo4j/interacting-with-neo4j-in-nodejs-using-the-neode-object-mapper-3d99cb324546).

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: [GitHub - adam-cowley/neode: Neo4j OGM for Node.js](https://github.com/adam-cowley/neode)  
Example Project: [GitHub - adam-cowley/neode-example: An example project using Neode](https://github.com/adam-cowley/neode-example)

Happy coding!

---

<div class="post-metadata">

**Author:** ![benfluleck](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/benfluleck/32/2523_2.png) [@benfluleck](https://community.neo4j.com/u/benfluleck)\
**Post date:** [December 16, 2018, 5:45pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/2 "2018-12-16T17:45:23Z")

</div>

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.

Thanks

---

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [December 17, 2018, 12:44pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/3 "2018-12-17T12:44:56Z")

</div>

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.

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

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

```

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

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

```

Let me know if that helps.

---

<div class="post-metadata">

**Author:** ![benfluleck](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/benfluleck/32/2523_2.png) [@benfluleck](https://community.neo4j.com/u/benfluleck)\
**Post date:** [December 17, 2018, 1:21pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/4 "2018-12-17T13:21:54Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [December 17, 2018, 1:52pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/5 "2018-12-17T13:52:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![benfluleck](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/benfluleck/32/2523_2.png) [@benfluleck](https://community.neo4j.com/u/benfluleck)\
**Post date:** [December 17, 2018, 2:11pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/6 "2018-12-17T14:11:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![benfluleck](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/benfluleck/32/2523_2.png) [@benfluleck](https://community.neo4j.com/u/benfluleck)\
**Post date:** [December 17, 2018, 6:06pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/7 "2018-12-17T18:06:02Z")

</div>

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

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

  }
)

```

---

<div class="post-metadata">

**Author:** ![knightkronos9510](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/knightkronos9510/32/3433_2.png) [@knightkronos9510](https://community.neo4j.com/u/knightkronos9510)\
**Post date:** [February 22, 2019, 8:36pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/8 "2019-02-22T20:36:57Z")

</div>

Hi @adam_cowley I having issues with neode, please see what I get when I try to create a node

 ![Captura](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/5/5e2970170a56bd8b92b9a01775776b728e4f9f91.jpeg)

As you can see when I run the create command using a neode instance the promise didn't resolve sucessfuly, I review also the model and connection settings are right, so I don't know what's wrong, Would you help me?

---

<div class="post-metadata">

**Author:** ![greta](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/greta/32/56_2.png) [@greta](https://community.neo4j.com/u/greta)\
**Post date:** [February 25, 2019, 10:55am UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/9 "2019-02-25T10:55:32Z")

</div>

Thanks for submitting!

I’ve added a tag that allows your blog to be displayed on the community home page!

---

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [February 25, 2019, 12:03pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/10 "2019-02-25T12:03:52Z")

</div>

I don't think the function in the router is asynchronous, I'm not sure whether removing `async` will solve the problem or not.

You can also use res.toJson() to return a cleaner JSON object with its properties rather than using JSON.stringify.

What version of neode are you using? Do you have a repository that I can clone and take a look at?

---

<div class="post-metadata">

**Author:** ![simon1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/simon1/32/3205_2.png) [@simon1](https://community.neo4j.com/u/simon1)\
**Post date:** [March 20, 2019, 12:47pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/11 "2019-03-20T12:47:49Z")

</div>

Hi, I'm having some trouble understanding what I have to do. I have used:

```auto
.with({
    User: require('./models/User'),
    Skill: require('./models/Skill')
  })

```

And  
`.schema.install().then(() => console.log('schemas installed')))`

But my models don't appear in the db until I create a node of that type?

What does `.schema.install()` actually do? And do I have to do any `.model()` commands?

Regards

---

<div class="post-metadata">

**Author:** ![stuartgw1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stuartgw1/32/6228_2.png) [@stuartgw1](https://community.neo4j.com/u/stuartgw1)\
**Post date:** [September 15, 2019, 3:49am UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/12 "2019-09-15T03:49:37Z")

</div>

Hi Adam.  
I'm trying to do a simple find and update but having no success.  
Based on combining a couple of your examples I expected to code:

```auto
instance.first('Person', 'name', 'Adam')
    .then(adam => adam.update({age: 29}));

```

But this produces the following error:  
ValidationError: child "person\_id" fails because ["person\_id" is required]

When I check the person object in debug it has an id value.

Any assistance would be most welcome.

---

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [October 9, 2019, 1:40pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/13 "2019-10-09T13:40:44Z")

</div>

Sorry for the delay in replying. This is something that has been bugging me for a while. I published 0.3.4 last night which should fix this issue. Let me know how you get on.

---

<div class="post-metadata">

**Author:** ![stuartgw1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stuartgw1/32/6228_2.png) [@stuartgw1](https://community.neo4j.com/u/stuartgw1)\
**Post date:** [October 9, 2019, 8:56pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/14 "2019-10-09T20:56:58Z")

</div>

Thanks Adam. However, I've gone back to basics.  
I'm just using the raw browser version of the Neo4j Driver which is sufficient for my needs now that I've figured out how it works.  
I wish you well with this project.

---

<div class="post-metadata">

**Author:** ![joelnash](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/joelnash/32/4370_2.png) [@joelnash](https://community.neo4j.com/u/joelnash)\
**Post date:** [May 26, 2020, 6:05pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/15 "2020-05-26T18:05:28Z")

</div>

Hi Adam,  
I am new to Neo4j (have done a small amount of work using Mongoose on Nodejs) and would like to evaluate Neode using the Neode-example application from GitHub. I have set up a 10 day evaluation of the Neo4j sandbox but am not able to connect to the sandbox database from the example application on my computer. My instance of the sandbox movies database tells me to use the following connection details:  
Username:neo4j  
Password:pointers-exchange-checkout  
IP Address:100.26.209.30  
HTTP Port:33969  
Bolt Port:33968  
Neo4j Browser: [https://10.0.1.26-33969.neo4jsandbox.com/](https://10.0.1.26-33969.neo4jsandbox.com/)  
Bolt URL: bolt://100.26.209.30:33968  
Websocket Bolt URL: bolt://ws-10-0-1-26-33968.neo4jsandbox.com:443/

In .env file of the Neode-example app I entered:  
NEO4J\_PROTOCOL=bolt  
NEO4J\_HOST=bolt://100.26.209.30:33968  
NEO4J\_USERNAME=neo4j  
NEO4J\_PASSWORD=pointers-exchange-checkout  
NEO4J\_PORT=33968

What am I doing wrong? Any guidance would be appreciated.  
Thanks,  
Joel

---

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [May 26, 2020, 6:14pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/16 "2020-05-26T18:14:35Z")

</div>

Hey Joel,

The host should just be the IP address rather than with the protocol and port. Try this line instead:

```auto
NEO4J_HOST=100.26.209.30

```

---

<div class="post-metadata">

**Author:** ![joelnash](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/joelnash/32/4370_2.png) [@joelnash](https://community.neo4j.com/u/joelnash)\
**Post date:** [May 26, 2020, 6:22pm UTC](https://community.neo4j.com/t/neode-object-graph-mapper-for-node-js/524/17 "2020-05-26T18:22:54Z")

</div>

> [@adam\_cowley](#):
>
> `100.26.209.30`

Thanks, I am now connected but am getting an error: "Neo4jError: Driver is connected to the database that does not support multiple databases. Please upgrade to neo4j 4.0.0 or later in order to use this functionality." Would I be better off loading Neo4j and the database from the sandbox on my computer? I am a newbie on this so don't want to waste a lot of your time.
