简体   繁体   English

OrientDB如何获取(分组的)关系数据作为JSON而不是对象

[英]OrientDB How to get (grouped) relational data as JSON instead of objects

I'm pretty new to OrientDB and tried to find an answer online or in the docs but can not find it. 我对OrientDB还是很陌生,并尝试在线或在文档中找到答案,但找不到它。

If i'm writing a MATCH query and returning grouped results I can only get the Id's of the records. 如果我正在编写MATCH查询并返回分组结果,那么我只能获取记录的ID。

My Query: 我的查询:

MATCH {class: SKU, as: sku}-categorizedIn->{class:Category, as: subcat}<-hasSubcategory-{class: Category, as: cat, where: (name='Drinks')}
RETURN subcat.name, CONCAT(sku)
GROUP BY subcat.name

This returns something like: subcat.name 返回类似:subcat.name

concat    |   (sku, ',')
--------------------------------
Wine      |   #46:0,#50:0,#49:0
Beer      |   #48:0,#47:0,#46:1 

How can i get a combined result that contains all the data like: 如何获得包含所有数据的组合结果,例如:

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" }]

Thanks in advance! 提前致谢!

You can use the .toJSON() method to get all the data you need: 您可以使用.toJSON()方法获取所需的所有数据:

Syntax: <value>.toJSON([<format>]) 语法: <value>.toJSON([<format>])

Source: SQL Methods > .toJSON() 资料来源: SQL方法> .toJSON()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM