简体   繁体   中英

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:

FOR p IN posts
  COLLECT channel = p.channel_key WITH COUNT INTO count
  RETURN { channel, count }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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