title: OrientDB How to get (grouped) relational data as JSON instead of objects
body: <p>I'm pretty new to OrientDB and tried to find an answer online or in the docs but can not find it.</p>
  
  <p>If i'm writing a MATCH query and returning grouped results I can only get the Id's of the records.</p>
  
  <p>My Query:</p>
  
  <pre><code>MATCH {class: SKU, as: sku}-categorizedIn-&gt;{class:Category, as: subcat}&lt;-hasSubcategory-{class: Category, as: cat, where: (name='Drinks')}
  RETURN subcat.name, CONCAT(sku)
  GROUP BY subcat.name
  </code></pre>
  
  <p>This returns something like:
   subcat.name</p>
  
  <pre><code>concat    |   (sku, ',')
  --------------------------------
  Wine      |   #46:0,#50:0,#49:0
  Beer      |   #48:0,#47:0,#46:1 
  </code></pre>
  
  <p>How can i get a combined result that contains all the data like:</p>
  
  <pre><code>concat    |   (sku, ',')
  --------------------------------
  Wine      |   [{_id: "#46:0", name: "Merlot" },{_id: "#50:0", name: "Pinot" },{_id: "#49:0", name: "Shiraz" }]
  Beer      |   [{_id: "#48:0", name: "Budweiser light" },{_id: "#47:0", name: "Stella Artroix" },{_id: "#46:1", name: "Heineken" }]
  </code></pre>
  
  <p>Thanks in advance!</p>