How to type foreign keys in TypeScript? #5773
Replies: 4 comments
-
|
Agree that there should be a higher order generic provided by Supabase to let us more easily type populated foreign table data. Very simple example from my own project, I have a db.from<definitions['photos'] & { image: definitions['images'] }>('photos') |
Beta Was this translation helpful? Give feedback.
-
|
Bump. I feel like this feature is required if you work with Typescript and foreign keys. |
Beta Was this translation helpful? Give feedback.
-
|
I am facing the same issue at work, would be great to have a solution other than @madeleineostoja 's. I have been doing that and it feels quite verbose. |
Beta Was this translation helpful? Give feedback.
-
|
Have the same issue, anyone? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
(I am just starting to learn Supabase and don't know PostgreSQL from before)
I have this key in one of my tables:
which is a reference to another table called
profiles. In my app I have some queries that populates this key with the data in theprofilestable, and some queries that doesn't.What is the best way to type this in TypeScript? If I make the
ownerkey typeowner: ProfileEntity | stringit gets really cumbersome to work with. Maybe I should create two types, one for when I populate the reference and one for when I don't, but that also seems pretty verbose considering there will be many different combinations of populating/not populating as the project grows. Am I missing something obvious?Beta Was this translation helpful? Give feedback.
All reactions