Skip to content

Commit 7891ef9

Browse files
committed
refactor: Postgrest*Response typings
1 parent 7fddd75 commit 7891ef9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/types.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,25 @@ interface PostgrestResponseBase {
2121
status: number
2222
statusText: string
2323
}
24-
25-
interface PostgrestResponseSuccess<T> extends PostgrestResponseBase {
24+
interface PostgrestSingleResponseSuccess<T> extends PostgrestResponseBase {
2625
error: null
27-
data: T[]
26+
data: T
2827
count: number | null
2928
}
3029
interface PostgrestResponseFailure extends PostgrestResponseBase {
3130
error: PostgrestError
3231
data: null
3332
count: null
3433
}
35-
export type PostgrestResponse<T> = PostgrestResponseSuccess<T> | PostgrestResponseFailure
3634

37-
interface PostgrestSingleResponseSuccess<T> extends PostgrestResponseBase {
38-
error: null
39-
data: T
40-
count: number | null
41-
}
35+
// TODO: in v3:
36+
// - remove PostgrestResponse and PostgrestMaybeSingleResponse
37+
// - rename PostgrestSingleResponse to PostgrestResponse
4238
export type PostgrestSingleResponse<T> =
4339
| PostgrestSingleResponseSuccess<T>
4440
| PostgrestResponseFailure
4541
export type PostgrestMaybeSingleResponse<T> = PostgrestSingleResponse<T | null>
42+
export type PostgrestResponse<T> = PostgrestSingleResponse<T[]>
4643

4744
export type GenericTable = {
4845
Row: Record<string, unknown>

0 commit comments

Comments
 (0)