Yonben
02/21/2022, 4:59 PMusers
, groups
and groups_users
. The last one is a table containing `userId`/`groupId` links, to join between them.
What would be the ideal queries to get "All users of group `i`" and "All groups of user `j`"?Yonben
02/21/2022, 10:38 PMSELECT *
FROM summoners summ
INNER JOIN group_summoner gs ON summ."summonerId" = gs."summonerId"
(summoners are kind of users)Yonben
02/21/2022, 10:39 PMconst { data, error, status } = await this.supabaseClient
.from<definitions['group_summoner']>('groups_summoners')
.select(
`
*,
summoners (
name
)`,
)
.eq('groupId', id)
and I get Could not find a relationship between groups_summoners and summoners in the schema cache
Yonben
02/21/2022, 10:39 PMYonben
02/22/2022, 8:57 AMSELECT *
FROM summoners summ
INNER JOIN groups gr ON gr.id = 1
INNER JOIN group_summoner gs ON summ."summonerId" = gs."summonerId";
Yonben
02/22/2022, 9:03 AMconst { data, error, status } = await this.supabaseClient
.from<definitions['groups']>('groups')
.select(
`
*,
summoners (
name
)
`,
)
.eq('id', id);
I figure supabase/postgres knows how to follow the foreign key alone?Yonben
02/22/2022, 9:03 AMsilentworks
02/22/2022, 10:31 AMYonben
02/22/2022, 11:08 AM