<@107176742342402048> im fetching data from 2 ta...
# help
a
@silentworks im fetching data from 2 tables like this via endpoint
Copy code
const { data: events, error } = await supabase
            .from('event')
            .select('name,organiser, event_branding(*)')
            .eq('is_live', 'false');
and im getting the data and can pass the props to a component after the each block like this
Copy code
{#each events as event}
  <EventCard {...event} />
{/each}
however the coloums in the event_branding table is also an array, how do i get that out in the new component . sent a pick as well
n
Hello @Ape R Us! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! 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.
a
im using sveltekit*
update: i looped it over and it works but that doesnt seem efficient if i have 6 tables to pull from
s
Are you saying there are multiple rows in the
event_branding
table that are related to the
event
?
n
Ape R Us (2022-04-11)
a
yep
also, is it that params can only be accessible for the main table or can it also be used for joining tables?
what i mean is so i have a table called "event" and a joining table called 'event_branding' event summaries are displayed so people can click and it goes to the actual event page
/e/{slug}
but because the event_branding is a join table i had to do a 2nd each block as shown in the pic above
but when time to call params, i kept getting errors so i had to take the url coloum and put it in the "event" table and it works now but is it possible or did i do something wrong?
the svelte file was
/e/[url]
link to go to the page ``href=[
/e/${branding.url}
]`` endpoint file
Copy code
import supabase from '$lib/db';

export const get = async ({ params }) => {
    try {
        const url = params.url;
        const { data: event, error } = await supabase
            .from('event')
            .select('*, event_branding(*),event_general(*)')
            .match({ url })
            .single();
        if (error) throw error;
        console.log(event);
        return {
            body: {
                event
            }
        };
    } catch (e) {
        console.log({ e });
    }
};