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

200
Vistas
Cypher Neo4j Return Multiple Variables (node.js Driver)

I want to query my Neo4j database and return multiple of the variables that I MATCH. Unfortunately, whenever I try this, I receive an error. I did a bit of research online and someone mentioned that returning multiple variables returns them as different columns rather than adding rows to the records. Or something like that. Since my two variables are of the same type, I do want them to be added as rows to the same array of records.

How do I do that?

Here's my Cypher Query, encapsulated in a JavaScript function for use in my Node.js server.

function getMyEvents(tx, userID) {
    return tx.run("MATCH (self:USER {userID: $userID})" +
        "MATCH (self)-[h:HOST]->(hostingEvents:EVENT) " +
        "MATCH (self)-[a:ATTENDING]-(attendingEvents:EVENT) " +
        "RETURN attendingEvents, hostingEvents",
        {"userID": userID})
}

I want both attendingEvents and hostingEvents to be returned as items in the same array / rows in the same record. Not as different columns or whatever was meant by the comments I encountered.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If I read your question correctly then what you want is to have match both the HOST and the ATTENDING relationship between self and the :EVENT? Then you can match multiple relationship types using |, giving you the Cypher

MATCH (self:USER {userID: $userID})
MATCH (self)-[:HOST|:ATTENDING]->(event:EVENT)
RETURN event

Note that I assume that both relationships have the same direction, if not then you can remove the > from the pattern.

about 4 years ago · Juan Pablo Isaza 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