【发布时间】:2023-02-15 21:22:00
【问题描述】:
我想抽象出一个类型的深层路径。
就在示例数据类型: (由 Supabase 生成的类型)
export interface Database {
public: {
Tables: {
profiles: {
Row: {
email: string;
full_name: string | null;
id: string;
is_complete: boolean;
};
Insert: {...};
Update: {...};
},
project: {...},
service: {...},
...
},
Views: {...},
...
};
};
什么是 uinder Row 是我试图分配给 varialbe 的数据结构。现在的方法是
const profiles: Database['public']['Tables']['profiles']['Row']
有没有办法以某种方式抽象它?
理想的抽象是:
const profiles: Profiles // Pointing to Database['public']['Tables']['profiles']['Row']
const profiles: SomeTypeSelectFunction['profiles'] // Could also do
一般来说,只能找到一些关于泛型的信息并限制它们,但似乎还没有找到一种方法来实现我正在寻找的东西。
【问题讨论】:
标签: typescript types supabase supabase-database