frubalu
08/02/2021, 2:50 PMconst { 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:
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!