You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't seem to figure out the best way to eager load the count of a related model. For example, if an account has subscriptions, how should you load the number of subscriptions on the account without having to select all subscriptions?
The best workaround I've been able to come up with is something like this:
There doesn't seem to be any way to just get a subscription count without having to select at least one field to return from the query. Is there a way just to return a count?
Not when using includes. Aggregates and includes/joins are generally tricker.
Usually what works best, atleast for PG, are window functions so you don't get those pesky aggregation errors.
Activity
mickhansen commentedon Mar 7, 2016
Not when using includes. Aggregates and includes/joins are generally tricker.
Usually what works best, atleast for PG, are window functions so you don't get those pesky aggregation errors.