How to aggregate for multiple levels of embedded resources? #3917
Unanswered
stefan-girlich
asked this question in
Q&A
Replies: 1 comment
-
Since this query has nested aggregates/group by mixed in between "has-many" and "has-one" relationships, it is too complex for a PostgREST query to resolve it. I'd go with a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using Supabase and PostgREST to aggregate sums by a nested property.
Resource hierarchy
locationsoutput_fractionsof which eachweightbatches) with aproject_typeshipmentswith another columnweightIn short:
locationshaveoutput_fractionswhich have one ofbatchesand manyshipmentsI want to query data for
locationsand aggregate nested weight sums:Case 1: Aggregate over 1 level
I want to aggregate
weightforoutput_fractionsbybatches.project_typewhich works fine:Case 2: Aggregating over more levels
I want to aggregate
weightforshipmentsbybatches.project_type.I wonder if I could modify this code to achieve the desired results:
Expected:
fractions2contains one item perproject_typeActual:
fractions2contains one item peroutput_fractionsitemIdeally, I could reference
shipmentsdirectly as an embedded resource, but this is not possible since it is does not relate directly tolocations, but only indirectly viaoutput_fractions.Is there an idiomatic way to achieve this? If not, how would tackle this problem?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions