假設你的圖具有頂點和邊緣類,是一種結構類似的:
您可以使用select
和圖形traverse查詢的組合來回報你所需要的。例如:
select from (traverse both('discuss'), both('started') from #14:0)
where (@class='room')
or (@class='user' and name='Julie')
這將返回以下結果(JSON格式)
{
"result": [
{
"@type": "d",
"@rid": "#13:0",
"@version": 3,
"@class": "room",
"name": "Baking",
"in_started": [
"#15:0"
],
"out_discuss": [
"#16:0"
],
"@fieldTypes": "in_started=g,out_discuss=g"
},
{
"@type": "d",
"@rid": "#12:0",
"@version": 2,
"@class": "user",
"name": "Julie",
"out_started": [
"#15:0"
],
"@fieldTypes": "out_started=g"
}
],
"notification": "Query executed in 0.027 sec. Returned 2 record(s)"
}
更新:
如果你只是想返回的@rid您可以用另一個選擇包裝上述查詢的房間:
select @rid from
(select from (traverse both('discuss'), both('started') from #14:0)
where (@class='room')
or (@class='user' and name='Julie'))
where @class='room'
請說明你想要查詢返回。 1)所有的項目和這些項目的任何房間由用戶'朱莉'開始。 2)只有Julie開始有房間的物品。 – neRok