我的项目后端是arangodb。我有两个名为" test"和"演示"。我需要从这两个表中获取数据。我的数据是这样的:
测试
[
{
"firstName": "abc",
"lastName": "pqr",
"company": "abc Industries",
"id": "1234"
},
{
"firstName": "xyz",
"lastName": "qwe",
"company": "xyz Industries",
"id": "5678"
}
]
演示
[
{
"clientId": "1234",
"subject": "test",
"message": "testing",
"priority": "High",
"status": "closed",
"id": "111111"
},
{
"clientId": "1234",
"subject": "hiii",
"message": "demo",
"priority": "High",
"status": "closed",
"id": "222222"
},
]
在这个测试的id中与demo的clientid相同。我需要从表中选择客户数据的数据" 1234"。我如何使用AQL(arango查询语言)实现这一点。我是arango的新手。任何建议都会非常明显。
答案 0 :(得分:1)
您可以使用joins或subqueries执行此操作。
子查询的解决方案如下所示:
FOR t IN test
FILTER t.id == @client
RETURN {
test: t,
demo: (FOR d IN demo
FILTER d.clientId == @client
RETURN d)
}
@client
是bind parameter,其中包含您的值1234
。
结果是:
[
{
"test": {
"_key": "140306",
"_id": "test/140306",
"_rev": "_Urbgapq---",
"company": "abc Industries",
"firstName": "abc",
"id": "1234",
"lastName": "pqr"
},
"demo": [
{
"_key": "140233",
"_id": "demo/140233",
"_rev": "_UrbfyAm---",
"clientId": "1234",
"id": "222222",
"message": "demo",
"priority": "High",
"status": "closed",
"subject": "hiii"
},
{
"_key": "140200",
"_id": "demo/140200",
"_rev": "_UrbfjfG---",
"clientId": "1234",
"id": "111111",
"message": "testing",
"priority": "High",
"status": "closed",
"subject": "test"
}
]
}
]
答案 1 :(得分:0)
For t in test
for d in demo
filter t.id == d.clientId
filter t.id == @client
return {t,d}
答案 2 :(得分:-1)
FOR collection IN [test,demo]
FOR x IN collection
RETURN x