Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda