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

201
Views
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 answers
Answer question

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 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!