type error In supabase join
Unanswered
0xtz posted this in #help-forum
0xtzOP
export const getAllLeadData = async (client_id: string) => {
const clientWithAddressAndStatut = supabase
.from("client")
.select(
`client_id, civility, first_name,
last_name, email, tel, type,
statut_id, processed_by, id_address_facturation, id_address_installation,
statut:statut_id ( id, name ),
address_facturation: id_address_facturation ( number, street, city, zip_code),
address_installation: id_address_installation ( number, street, city , zip_code)
`,
)
.eq("client_id", client_id)
.single();
type ClientWithAddressAndStatut = DbResultOk<
typeof clientWithAddressAndStatut
>;
const { data, error } = await clientWithAddressAndStatut;
if (error) throw new Error(error.message);
const typedClientWithAddressAndStatut: ClientWithAddressAndStatut = data;
return typedClientWithAddressAndStatut;
};the returned data have no errors 😕 but the type is not right
