0
Say I have two tables, clubs and posts. Each club can have many posts and my app stores a timestamp for when the user last viewed a post for each club (‘last_viewed’). What I want to do, is query for the number of all new posts (since that club was looked at) and display that value for each club.
Is that possible with Hasura, or will that query have to be broken up into n queries for n clubs?
The closest I could figure out is to query clubs where id is in an array of club ids, but I haven’t found a way to vary the timestamp input to the where clause of the post_aggregate.
query GetNewPostCounts($lastSeen: timestamp!, $clubIds: [uuid!]!) {
clubs(where: {id: {_in: $clubIds}}) {
id
post_aggregate(where: {created_at: {_gt: $lastSeen}}) {
aggregate {
count
}
}
}
}
Is there a way to query by passing in an array of object in this form below (or some other method), and run the query for each object in the array?
{
clubId: some uuid,
timestamp: some timestamp,
}