s c a p e g o a t
06/18/2022, 10:45 AM!inner join function in the JS client.
Currently the data I get from the database is like the image on the left. The database returns me an array of object which contains another object called images with the url inside it.
What I want to do is tell Postgres to return only array of urls from the the images table, which were obtained through the !inner join function via the table item_image.
(Continue in the thread --->)Needle
06/18/2022, 10:45 AMs c a p e g o a t
06/18/2022, 10:46 AMs c a p e g o a t
06/18/2022, 10:47 AMs c a p e g o a t
06/18/2022, 10:50 AMitems
-- id
-- name
images
-- id
-- url
item_image
-- item_id
-- image_id
I'm not really sure how to approach this problem since array of foreign keys are still not supported by Postgres. If there's a better way, please suggest. I don't think this one is the best solution either. :Ps c a p e g o a t
06/18/2022, 11:40 AMimages table actually have other columns called ref_table and ref_id which I created as reference so that I can chain with another call to Supabase after obtaining the initial dataset from items.
It turns out that I can use !inner with those two columns without setting up any actual foreign key relationships. I never tried this method when I built the APIs but it works so I guess my problem is solved then.