Skip to content

Commit eff88f9

Browse files
committed
fix: typings
1 parent b2028cd commit eff88f9

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/SupabaseClient.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,13 @@ export default class SupabaseClient<
151151
from<
152152
TableName extends string & keyof Schema['Tables'],
153153
Table extends Schema['Tables'][TableName]
154-
>(table: TableName): PostgrestQueryBuilder<Table>
155-
from(table: string): PostgrestQueryBuilder<any>
156-
from(table: string): PostgrestQueryBuilder<any> {
157-
return this.rest.from(table)
154+
>(relation: TableName): PostgrestQueryBuilder<Table>
155+
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(
156+
relation: ViewName
157+
): PostgrestQueryBuilder<View>
158+
from(relation: string): PostgrestQueryBuilder<any>
159+
from(relation: string): PostgrestQueryBuilder<any> {
160+
return this.rest.from(relation)
158161
}
159162

160163
/**

src/lib/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,25 @@ export type GenericTable = {
5959
Update: Record<string, unknown>
6060
}
6161

62+
export type GenericUpdatableView = {
63+
Row: Record<string, unknown>
64+
Insert: Record<string, unknown>
65+
Update: Record<string, unknown>
66+
}
67+
68+
export type GenericNonUpdatableView = {
69+
Row: Record<string, unknown>
70+
}
71+
72+
export type GenericView = GenericUpdatableView | GenericNonUpdatableView
73+
6274
export type GenericFunction = {
6375
Args: Record<string, unknown>
6476
Returns: unknown
6577
}
6678

6779
export type GenericSchema = {
6880
Tables: Record<string, GenericTable>
81+
Views: Record<string, GenericView>
6982
Functions: Record<string, GenericFunction>
7083
}

0 commit comments

Comments
 (0)