# Using neo4j in a custom database connection

**URL:** <https://community.auth0.com/t/using-neo4j-in-a-custom-database-connection/8537>\
**Category:** Get Help\
**Tags:** custom-database\
**Created:** [October 20, 2017, 4:00pm UTC](https://community.auth0.com/t/using-neo4j-in-a-custom-database-connection/8537 "2017-10-20T16:00:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kieryn.annette](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kieryn.annette](https://community.auth0.com/u/kieryn.annette)\
**Post date:** [October 20, 2017, 4:00pm UTC](https://community.auth0.com/t/using-neo4j-in-a-custom-database-connection/8537/1 "2017-10-20T16:00:00Z")

</div>

Does anyone have an example of using neo4j as a custom database?

How did you import the neo4j driver?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [October 20, 2017, 5:44pm UTC](https://community.auth0.com/t/using-neo4j-in-a-custom-database-connection/8537/2 "2017-10-20T17:44:59Z")

</div>

I’m not aware of any examples for Neo4j and also according to the [available modules to rules](http://neo4j-driver) which would be equivalent to the ones for custom database scripts there is no Neo4j specific module available (did a search for `neo4j`). I know this is not the first time such a request as came up and I previously suggested that a Neo4j related module could be made available (I think it was the driver module you refer); I’ll recheck again what’s the status of that suggestion.

Meanwhile, an always available possibility is to just broker the access through an HTTP API and use one of the available HTTP client modules (for example `request`) to perform the outgoing calls to your service.

---

<div class="post-metadata">

**Author:** ![nonybrighto](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@nonybrighto](https://community.auth0.com/u/nonybrighto)\
**Post date:** [February 23, 2018, 10:12pm UTC](https://community.auth0.com/t/using-neo4j-in-a-custom-database-connection/8537/3 "2018-02-23T22:12:31Z")

</div>

You can’t use the neo4j javascript driver since it is not currently supported by the webtask environment.  
You can make use of request module to communicate with the neo4j REST API as an alternative.

The code below is a hook i created for test to create a node in my graphenedb database when a user signs up.

```
module.exports = function (user, context, cb) {

    const request = require('request');
       
    var username = 'dbusername';
    var password = 'dbpassword';
    var auth = new Buffer(dbusername+':'+dbpassword).toString('base64');
        
    var headersG = {
        'Accept': 'application/json',
        'Authorization': 'Basic '+auth,
        'Content-Type': 'application/json'
    };
  var bodyStuffG = {
    "statements" : {
      "statement" : "CREATE (n:User{props}) RETURN n",
      "parameters" : {
        "props" : {
          "email" : user.email,
          'id': user.id
        }
      }
    } ]
};
  var options = {
      method: 'POST',
      url: 'https://hobby-hjifkhgdfhsdgbkeehdefaqs.dbs.graphenedb.com:24780/db/data/transaction/commit',
      headers: headersG,
      body:JSON.stringify(bodyStuffG)
    };
  
      request(options, function (error, response, body) {
          if(error){
            //hangle error
          }
         //do something with the body
      });
    cb();
  };

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:57am UTC](https://community.auth0.com/t/using-neo4j-in-a-custom-database-connection/8537/4 "2018-03-02T05:57:04Z")

</div>


