How to collect node property and relationship property together

Hi there! I'm trying to return what I can only best describe as a subquery. For example:


What I'd like to return is something like:,, {}
as there are multiple c:nodes and r:relationships per b:node.

I've looked into map projections but keep hitting a dead end. Any suggestions?

Thank you for your time

The tricky part of this is that with Cypher alone you cannot create a map with a dynamic property key (, it has to be literal.

There is a workaround you can use with helper functions from APOC Procedures, but make sure you actually need this as it complicates the query.

MATCH (a:User)-[:CREATED]->(b:Item) 
WITH as creator, as item, b
MATCH (c:User)-[r:PURCHASED]->(b)
RETURN creator, item,[], []) as purchaser
1 Like

Awesome, I think this did the trick. Thank you!