node.js - Cypher Query Return matched Nodes and optional relationships -
i trying find optimal way of returning matched nodes , relationships might have?
here's problem:
i need return users created project, so
match (u : user)-[r:create]->(p: project) return u, collect(p)
simple enough, user have other relationships , include them or optionally check (return true/false)
for example user have relationship recommend, don't want limit it, if check if exists node?
ideally return table this:
user1 - project(s) - recommended user
user2 - project(s) - null (nobody recommending)
optional match match pattern , return null if not exist
match (u : user)-[r:create]->(p: project) optional match (u)-[:recommend]->(rec) return u, collect(p), collect(rec)
Comments
Post a Comment