Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

274
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda