简体   繁体   English

在AQL中组合文档列表?

[英]Combining a list of documents in AQL?

I have a list of documents and would like to combine them into a single document. 我有一份文件清单,并希望将它们合并为一份文件。 The documentation for Arango says you can merge two documents like this: Arango的文档说你可以合并两个这样的文件:

arangosh [EC]> db._query('RETURN MERGE({foo: "bar"}, {fizz: "buzz"})', {}).toArray()
[ 
  { 
    "foo" : "bar", 
    "fizz" : "buzz" 
  } 
]

But the merge function does not accept lists: 但合并功能不接受列表:

arangosh [EC]> db._query('RETURN MERGE([{foo: "bar"}, {fizz: "buzz"}])', {}).toArray()
JavaScript exception in file '/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js' at 104,11: [ArangoError 1541: invalid number of arguments for function 'MERGE()', expected number of arguments: minimum: 2, maximum: 65536 (while parsing)]
!    throw new ArangoError(requestResult);

How do I combine documents together in AQL? 如何在AQL中将文档组合在一起?

I think it can be done using APPLY() . 我认为可以使用APPLY()来完成。

APPLY() takes a function name as its first parameter. APPLY()将函数名称作为其第一个参数。 The second parameter is an array of parameters for this function. 第二个参数是此函数的参数数组。 It will then call the function and make the array elements individual call parameters: 然后它将调用该函数并使数组元素成为单独的调用参数:

RETURN APPLY("merge", [{foo: "bar"}, {fizz: "buzz"})

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

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