https://supabase.com/ logo
Idea: I'd like to see a simpler API for accessing ...
# ideas-and-suggestions
f
Idea: I'd like to see a simpler API for accessing table relationships. Currently I have a query that looks like this:
Copy code
const { data: pack, error: packError } = await supabase
      .from('trip_packs')
      .select(
        `
          pack:pack_id(*, categories(*, category_items(*), items(*))) 
        `
      )
      .match({ trip_id: tripId, user_id: me.id });
As you can see, it's a fairly complicated select method, trying to access data several relationships deep. It could be cool to do something like Prisma, which looks like this:
Copy code
const getUser = await prisma.user.findUnique({
  where: {
    id: 19,
  },
  include: {
    posts: true,
  },
})
^ a user's posts are included. Or even better (I come from a Rails background), the ability to set up eager loading relationships. So in my first example, I would just query for a Pack, and all of the nested categories and items would automatically be included in the query. Thanks for coming to my Ted Talk!