title: How to return a composite object in Neo4j/Cypher
body: <p>I'd like to return a composite object from Neo4j using cypher to tidy up my queries.</p>
  
  <p>To give an example, I have a user account object that has permissions stored as relationships. The permissions are complex objects so can't be nested, they are now linked by the relationship [:HAS_PERMISSION]. What i'd like to do is return the full complex object with the permissions already nested, like in the example JSON object below</p>
  
  <pre><code>e.g.
  
  permissions:
  {
      action:'delete', 
      resource:'blog posts'
  }
  {
      action:'edit', 
      resource:'users'
  }   
  
  core user account:
  {
    username:'Dave',
    email:'dave@test.com'
  }
  
  What i'd like:
   {
    username:'Dave',
    email:'dave@test.com'
    permissions: [{action:'delete', resource:'blog posts'},{action:'edit', resource:'users'}]
   }
  </code></pre>
  
  <p>The query I currently have:</p>
  
  <pre><code>MATCH(user:UserAccount)-[:HasPermission]-&gt;(permission:Permission)
  WITH {user:user, permissions:collect(permission)} AS UserAccount
  RETURN UserAccount
  </code></pre>
  
  <p>The problem is this doesn't quite return what i'm after, it returns this:</p>
  
  <pre><code>{
       user: {
       username:'Dave',
       email:'dave@test.com'
       },
       permissions: [{action:'delete', resource:'blog posts'},{action:'edit', resource:'users'}]
   }
  </code></pre>
  
  <p>Please note: I'd really like to add the permissions list to the <strong>existing user object</strong> i'm returning please. I'd like to know how to save me having to explicitly declare all of the properties I need on the new object (if it's possible).</p>