Nested and Complex Queries With Supabase and Typescript

preview_player
Показать описание
Supabase offers a great client library with Typescript support, however if you need to perform any kind of complex query it might require some additional steps. In this video, I quickly walk through how to create a Postgres view for your query and how to generate the Typescript types for this view. #supabase #postgres #webdevelopment #javascript @Supabase
Рекомендации по теме
Комментарии
Автор

Great video, just want to note that you created a view, not a materialized view as you mentioned in the video. Thanks for sharing

kyle.rummens
Автор

This was huge!!! My SQL query was working fine, but the supabase inquiry in my TypeScript file was resulting in two fields being null. Querying the created view instead gave me what I was looking for!

jwbw
Автор

Is there a way to use the response from the view as a type in TS?

Something like
import type { Tables } from

export async function getMeals(): Promise<{ meals: }> {
const { data, error } = await

if (error) {
console.log(error);
throw new Error(error.message);
}

return { meals: data };
}

(where MealsWithIngredients is a view)

mekins
visit shbcf.ru