Reputation: 29
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})
Upvotes: 0
Views: 48
Reputation: 11885
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 }
Upvotes: 1