Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
MongoDB Atlas triggers don't work with Neo4j driver

My goal is to create an Atlas triggers to synchronize my MongoDB database with a Neo4j (Aura) database. The function I wrote works fine on my computer, however, when called by the trigger it throws this error:

TypeError: Configured resolver function should either return an array of addresses or a Promise resolved with an array of addresses.Each address is '<host>:<port>'. Got: [object Promise]

This is the function:

(async () => {
  const neo4j = require("neo4j-driver");

  const uri = "neo4j+s://d3dc4645.databases.neo4j.io";
  const user = "neo4j";
  const password = "...";

  const driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
  const session = driver.session();

  const id = "TEST"
  
  const writeQuery = `MERGE (p1:User {id:$id })`;
  await session.writeTransaction((tx) => tx.run(writeQuery, { id }));
  await driver.close();
})();

In the trigger it is like this (this doesn't work):

exports = async function(changeEvent) {

  const neo4j = require("neo4j-driver");

  const uri = "neo4j+s://d3dc4645.databases.neo4j.io";
  const user = "neo4j";
  const password = "...";

  const driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
  const session = driver.session();

  const id = "TEST"
  
  const writeQuery = `MERGE (p1:User {id:$id })`;
  await session.writeTransaction((tx) => tx.run(writeQuery, { id }));
  await driver.close();
};

I honestly have no idea what the problem is. I can guess that it derives from some incompatibility of that dependence or in any case, is linked to the way in which promises are managed. What am I doing wrong?

It's still a limiting problem for me...

Update after the reply of @NBekelman.

I have already tried in the following days to change the code but unfortunately, the error message is always the same.

exports =  function(changeEvent) {
  [...]
  
  const driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
  const session = driver.session({ defaultAccessMode: neo4j.session.WRTIE });

  
  console.log(session); // <-- so far so good
  
  
  const writeQuery = `MERGE (p1:User {id:"TEST" })`;

  session.run(writeQuery) // <-- error
    .then(result => {
        console.log(result);
    })
    .then(() => session.close()); 

  
  driver.close();
};
 
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are returning a Promise but the function you are using expect to a value (by the error, the type should be <host>:<port>;

Also I think you should use

module.exports = ... // default exports
exports.handler = ... // named exports

module exports nodejs

Publish the consumer of this function for more help if needed.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!