Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

PostgrestBuilder

abstract
abstract 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]
§
Result
[src]
§
ThrowOnError extends boolean = false
[src]

§Implements

§
PromiseLike<ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>>
[src]

§Constructors

§
new PostgrestBuilder(builder: {
method:
| "GET"
| "HEAD"
| "POST"
| "PATCH"
| "DELETE";
url: URL;
headers: HeadersInit;
schema?: string;
body?: unknown;
shouldThrowOnError?: boolean;
signal?: AbortSignal;
fetch?: Fetch;
isMaybeSingle?: boolean;
}
)
[src]

§Properties

§
body: unknown
[src]
§
fetch: Fetch
[src]
§
headers: Headers
[src]
§
isMaybeSingle: boolean
[src]
§
method: "GET" | "HEAD" | "POST" | "PATCH" | "DELETE"
[src]
§
schema: string
[src]
§
shouldThrowOnError: boolean
[src]
§
signal: AbortSignal
[src]
§
url: URL
[src]

§Methods

§
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>
[src]

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

§
setHeader(name: string, value: string): this
[src]

Set an HTTP header for the request.

§
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.

https://github.com/supabase/supabase-js/issues/92