I'm trying to undestand how to properly use relati...
# help
p
I'm trying to undestand how to properly use relational data. I have a table "Projects" and "Managers". Each project has a column
manager
with a foreign key to manager's
id
. So. what if I want to display manager's
name
row instead of
id
? I've tried this but it doesn't work
Copy code
Svelte
{#each projects as project}        
    {project.manager.name || ''}       
{/each}
n
Hello @Phenomen! 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.
o
Hi What does your ``projects`` variables contains? @Phenomen
p
Hey It's data from Supabase's
projects
table
Copy code
js
    async function getProjects() {
        try {
            loading = true;
            let { data, error } = await supabase
                .from('projects')
                .select('*')
                .eq('isActive', true)
                .order('created_at', { ascending: false });
            projects = data;
        } catch (error) {
            alert(error.message);
        } finally {
            loading = false;
        }
    }
Okay, after some googling I found a solution:
Copy code
js
.select('*, manager ( name )')
o
Exactly, this is the way to fetch deep datas :p
n
Thread was archived by @Phenomen. Anyone can send a message to unarchive it.