#Use supabase types

14 messages · Page 1 of 1 (latest)

wary hawk
glass canopy
#

usig indexed access

#

!hb indexed access

upper craneBOT
glass canopy
#

tlrd. you can "take" a (sub-) attribute of a type

#

and use it to create a new type with that

#
type Comment = Database["public"]["Tables"]["comments"]["Row"];
#

you might want to automate the "extraction" of that information with an utility type

#
type DBRow<T extends keyof Database["public"]["Tables"]> = Database["public"]["Tables"][T]["Row"];

type Comment = DBRow<"comments">;
type Country = DBRow<"countries">;
type Image = DBRow<"images">;
// etc.
glass canopy
#
type Comment = Tables<"comments">;
type Country = Tables<"countries">;
type Image = Tables<"images">;

I think
tho Tables can take a 2nd type parameter, but not too sure what it's supposed to be exactly

#

@wary hawk

#

have you tried searching for documentation about that generator, and how to use it?

wary hawk