[英]Get the number of linked documents to a collection in Arangodb
i have a collection called "channels" and it has documents linked to it in a collection called "posts".我有一个名为“频道”的集合,它在一个名为“帖子”的集合中有链接到它的文档。
Instead of getting the actual documents, how can i just get a number of how many they are.而不是获取实际的文档,我怎样才能得到它们的数量。 so i can print out
这样我就可以打印出来
"this channel has # amount of posts" “这个频道有 # 条帖子”
FOR c IN channels
LET posts= (FOR p IN posts
FILTER c._key== p.channel_key
RETURN p)
RETURN merge(channels,{posts})
Based on your example, it might be as simple as to group by the channel_key
and count how many posts fall into each group:根据您的示例,它可能就像按
channel_key
分组并计算每个组中有多少帖子一样简单:
FOR p IN posts
COLLECT channel = p.channel_key WITH COUNT INTO count
RETURN { channel, count }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.