# How to collect node property and relationship property together

**URL:** https://community.neo4j.com/t/how-to-collect-node-property-and-relationship-property-together/3745
**Category:** Cypher
**Tags:** cypher
**Created:** [December 10, 2018, 10:19pm UTC](https://community.neo4j.com/t/how-to-collect-node-property-and-relationship-property-together/3745 "2018-12-10T22:19:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![henry.macafee](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/henry.macafee/32/700_2.png) [@henry.macafee](https://community.neo4j.com/u/henry.macafee)
#### Post date: [December 10, 2018, 10:19pm UTC](https://community.neo4j.com/t/how-to-collect-node-property-and-relationship-property-together/3745/1 "2018-12-10T22:19:38Z")

</div>

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

```auto
(a:User)-[:CREATED]->(b:Item)
(c:User)-[r:PURCHASED]->(b)

```

What I'd like to return is something like:  
`a.name, b.name, {c.name: r.date}`  
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

---

<div class="post-metadata">

### Author: ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)
#### Post date: [December 10, 2018, 11:10pm UTC](https://community.neo4j.com/t/how-to-collect-node-property-and-relationship-property-together/3745/2 "2018-12-10T23:10:08Z")

</div>

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

There is a workaround you can use with [helper functions from APOC Procedures](https://neo4j-contrib.github.io/neo4j-apoc-procedures/#_map_functions), but make sure you actually need this as it complicates the query.

```auto
MATCH (a:User)-[:CREATED]->(b:Item) 
WITH a.name as creator, b.name as item, b
MATCH (c:User)-[r:PURCHASED]->(b)
RETURN creator, item, apoc.map.fromLists([c.name], [r.date]) as purchaser

```

---

<div class="post-metadata">

### Author: ![henry.macafee](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/henry.macafee/32/700_2.png) [@henry.macafee](https://community.neo4j.com/u/henry.macafee)
#### Post date: [December 10, 2018, 11:27pm UTC](https://community.neo4j.com/t/how-to-collect-node-property-and-relationship-property-together/3745/3 "2018-12-10T23:27:59Z")

</div>

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