PostgrestBuilder
abstractabstract class PostgrestBuilder<ClientOptions extends ClientServerOptions, Result, ThrowOnError extends boolean = false> implements PromiseLike<ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>> { }
constructor(builder: {
method:
| "GET"
| "HEAD"
| "POST"
| "PATCH"
| "DELETE";
url: URL;
headers: HeadersInit;
schema?: string;
body?: unknown;
shouldThrowOnError?: boolean;
signal?: AbortSignal;
fetch?: Fetch;
isMaybeSingle?: boolean;
});protected body?: unknown;
protected fetch: Fetch;
protected headers: Headers;
protected isMaybeSingle: boolean;
protected method:
| "GET"
| "HEAD"
| "POST"
| "PATCH"
| "DELETE";
protected schema?: string;
protected shouldThrowOnError: boolean;
protected signal?: AbortSignal;
protected url: URL;
overrideTypes<NewResult, Options extends {
merge?: boolean;
} = {merge: true;
}>(): PostgrestBuilder<ClientOptions, IsValidResultOverride<Result, NewResult, false, false> extends true ? ContainsNull<Result> extends true ? MergePartialResult<NewResult, NonNullable<Result>, Options> | null : MergePartialResult<NewResult, Result, Options> : CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError>;returns<NewResult>(): PostgrestBuilder<ClientOptions, CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError>;
setHeader(name: string, value: string): this;
then<TResult1 = ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>, TResult2 = never>(onfulfilled?: ((value: ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
throwOnError(): this & PostgrestBuilder<ClientOptions, Result, true>;
§Type Parameters
§
ClientOptions extends ClientServerOptions
[src]§Implements
§
PromiseLike<ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>>
[src]§Constructors
§Properties
§Methods
§
overrideTypes<NewResult, Options extends {
[src]merge?: boolean;
} = {merge: true;
}>(): PostgrestBuilder<ClientOptions, IsValidResultOverride<Result, NewResult, false, false> extends true ? ContainsNull<Result> extends true ? MergePartialResult<NewResult, NonNullable<Result>, Options> | null : MergePartialResult<NewResult, Result, Options> : CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError>Override the type of the returned data
field in the response.
@example
// Merge with existing types (default behavior)
const query = supabase
.from('users')
.select()
.overrideTypes<{ custom_field: string }>()
// Replace existing types completely
const replaceQuery = supabase
.from('users')
.select()
.overrideTypes<{ id: number; name: string }, { merge: false }>()
@return
A PostgrestBuilder instance with the new type
§
returns<NewResult>(): PostgrestBuilder<ClientOptions, CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError> deprecated
[src]Override the type of the returned data
.
@deprecated
Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead
§
then<TResult1 = ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>, TResult2 = never>(onfulfilled?: ((value: ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>
[src]§
throwOnError(): this & PostgrestBuilder<ClientOptions, Result, true>
[src]If there's an error with the query, throwOnError will reject the promise by throwing the error instead of returning it as part of a successful response.