Hi, thank you for your answer ! That could be a solution when I only retrieve the user’s payments and there’s not a lot of them.
Problem is : I also have an admin dashboard, with a view that shows all the payments from all the users in a server-paginated table. In this view I also would like to have stats ( so for example, the sum of all the payments amount from all users in a given time range).
My table is paginated so I cannot use its payload to calculate this amount if I have more than 1 page. I could create another endpoint just to calculate those stats, and use findMany, then loop and sum the amounts manually, but that would be expensive on a relatively big array of payments ? ( like 1000-5000 items ) ?
That’s why I thought about aggregation…