Hey! I just heard of , and got started with supaba...
# help
b
Hey! I just heard of , and got started with supabase. Great experience so far! I have a table called
talents
and one of its column is of
INT[]
which is an array referencing the column
id
of another table called
skills
. When I run the following query it runs fine, but for the column
skills
I currently get for example [1,8,19], when I'd like to instead return its `name`column like ['Engineering','Python','Solidity']
Copy code
let { data, error } = await supabase
    .from('talents')
    .select("*")
    .order('id', { ascending: false })
    .limit(5)
How would I modify above query to get the values from a foreign table?
n
Hello @Big Bird! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
b
g
You can't use foreign keys in an array. You can load the skills table and then use it to map the array when you later select it. You could write an rpc function on the Postgres side to convert the array with selects to the skills table.
b
Ok, the first option sounds ok. So I'd make 2 queries and map the results together in a separate action?
g
Basically put your skills into an array from first select. Then after you get the talents back, you convert the numeric array to the skill names in javascript using the the skills table by inderx.
If you have 1000's of skills, this is probably not best approach though.
b
Roger, thanks for the help!
n
Thread was archived by @Big Bird. Anyone can send a message to unarchive it.