title: Retrieve data as an array of Objects in Neo4j
body: <p>There are many relationships and nodes. We want to retrieve data as an array of objects from Neo4j database.</p>
  
  <p>If we MATCH as :</p>
  
  <pre><code>MATCH (user: user {name:"x"}) 
  OPTIONAL MATCH (user)-[r]-&gt;(item)
  OPTIONAL MATCH (item)-[s]-&gt;(approver)
  RETURN user, item, approver
  </code></pre>
  
  <p>We get the result as:</p>
  
  <pre><code>[{user:{properties:{name:"x"}}, item:{properties:{name:"abc"}}, approver:{properties:{name:"a"}}},
  {user:{properties:{name:"x"}}, item:{properties:{name:"abc"}}, approver:{properties:{name:"b"}]}},
  {user:{properties:{name:"x"}}, item:{properties:{name:"xyz"}}, approver:{properties:{name:"c"}}},
  {user:{properties:{name:"x"}}, item:{properties:{name:"xyz"}},  approver:{properties:{name:"d"}}}  }]
  </code></pre>
  
  <p>We need to get the result similar to inorder to reduce the complexity while handling huge relationships at the client side:</p>
  
  <pre><code>[{user:{properties:{name:"x"}}, item:{properties:{name:"abc"}},  approvers:[{properties:{name:"a"}}, {properties:{name:"b"}}]},    
  {user:{properties:{name:"x"}}, item:{properties:{name:"xyz"}}, approvers:[{properties:{name:"c"}}, {properties:{name:"d"}}] }]
  </code></pre>
  
  <p>How to do this?</p>