Resource embedding with a one-to-one view #1895
-
Hi there! I'm trying to use Supabase (with PostgREST 😃), and I have the following schema:
Extended definition from psql
I'm trying to query with a one-to-one mapping. Calling
Looking at the documentation, seems that embedding views should work. Why would that be? Am I doing something wrong? At first I thought that maybe it's related to the join over SELECT profiles.id AS profile_id,
'https://hello/'::text || profiles.id AS url
FROM profiles; Any assistance will be much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @Schniz,
Yes, embedding views work as long as there are foreign key relationships on the tables it's based on. The For this case, you could make a VIEW of the |
Beta Was this translation helpful? Give feedback.
Hey @Schniz,
Yes, embedding views work as long as there are foreign key relationships on the tables it's based on.
The
derived_avatars
view is basically theprofiles
table underneath, and there's no foreign key relationship betweenprofiles
andprofiles
- so it's not really a one-to-one relationship.For this case, you could make a VIEW of the
users
table(hiding some columns), saymy_users
, and then you should be able to embedprofiles
withmy_users
(/profiles?select=*,my_users(*)
).