Ordering by foreign key count #7875
-
Hi, is it possible to do something like this: await supabase.from("groups").select('*, items(id)').order('items.count'); Basically, sort resulting groups by the number of items tied to that group ( |
Beta Was this translation helpful? Give feedback.
Answered by
steve-chavez
Jul 26, 2022
Replies: 1 comment 5 replies
-
Not possible directly for now but you can do so with a computed column. create function items_count(groups) returns bigint as $$
select count(*) from items where group_id = $1.id;
$$ stable language sql; await supabase.from("groups").select('*, items(id)').order('items_count'); |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
brycedorn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not possible directly for now but you can do so with a computed column.