我可以返回类似的内容:
var questionOne = new Quiz("What is his first name?", "Elon", "/Assets/emusk.jpg", new string[]{"Peter","John","Mark"});
来自AQL查询?这个想法就像(这个非工作代码):
{
"c/12313" = 1,
"c/24223" = 2,
"c/43423" = 3,
...
}
其中for c in my_collection
return { c._id : c.sortOrder }
是我文档中的某些属性。
答案 0 :(得分:3)
是的,可以dynamic attribute names:
LET key = "foo"
LET value = "bar"
RETURN { [ key ]: value } // { "foo": "bar" }
计算属性键的表达式必须包含在[
方括号]
中,就像在JavaScript中一样。
然而,这并没有返回所需的结果:
FOR c IN my_collection
RETURN { [ c._id ]: c.sortOrder }
[
{ "c/12313": 1 },
{ "c/24223": 2 },
{ "c/43423": 3 },
...
]
要不为每个键返回单独的对象,MERGE()和子查询是必需的:
RETURN MERGE(
FOR c IN my_collection
RETURN { [ c._id ]: c.sortOrder }
)
[
{
"c/12313": 1,
"c/24223": 2,
"c/43423": 3,
...
}
]