I have a profiles table and a subscriptions table that has the primary key of profile_id that references the id of profiles as a foreign key.
Profiles:
Subscriptions:
As you can see below the profile id in subscriptions matches the id of profile. However when I try to select the subscription I always get null.
<code> const { data: profile, error: profileError } = await supabaseAdmin
.from("profiles")
.select(
`*,
subscriptions!profile_id(
*
)
`
)
.eq("user_id", user.id)
.single();
</code>
<code> const { data: profile, error: profileError } = await supabaseAdmin
.from("profiles")
.select(
`*,
subscriptions!profile_id(
*
)
`
)
.eq("user_id", user.id)
.single();
</code>
const { data: profile, error: profileError } = await supabaseAdmin
.from("profiles")
.select(
`*,
subscriptions!profile_id(
*
)
`
)
.eq("user_id", user.id)
.single();
I’ve also tried referrencing the foreign key directly without luck.
<code> const { data: profile, error: profileError } = await supabaseAdmin
.from("profiles")
.select(
`*,
subscriptions!subscriptions_profile_id_fkey(
*
)
`
)
.eq("user_id", user.id)
.single();
</code>
<code> const { data: profile, error: profileError } = await supabaseAdmin
.from("profiles")
.select(
`*,
subscriptions!subscriptions_profile_id_fkey(
*
)
`
)
.eq("user_id", user.id)
.single();
</code>
const { data: profile, error: profileError } = await supabaseAdmin
.from("profiles")
.select(
`*,
subscriptions!subscriptions_profile_id_fkey(
*
)
`
)
.eq("user_id", user.id)
.single();
Any suggestions on how to get the subscription would be greatly appreciated!
I figured it out, had to do with RLS policy.