Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PostgrestBuilder<Result, ThrowOnError> Abstract

Type Parameters

  • Result

  • ThrowOnError extends boolean = false

Hierarchy

Implements

Index

Constructors

Properties

body?: unknown
fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)

Type declaration

    • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
    • Parameters

      • input: RequestInfo | URL
      • Optional init: RequestInit

      Returns Promise<Response>

headers: Record<string, string>
isMaybeSingle: boolean
method: "GET" | "HEAD" | "POST" | "PATCH" | "DELETE"
schema?: string
shouldThrowOnError: boolean = false
signal?: AbortSignal
url: URL

Methods

  • overrideTypes<NewResult, Options>(): PostgrestBuilder<IsValidResultOverride<Result, NewResult, false, false> extends true ? ContainsNull<Result> extends true ? null | MergePartialResult<NewResult, NonNullable<Result>, Options> : 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 }>()

    Type Parameters

    • NewResult

      The new type to cast the response data to

    • Options extends { merge?: boolean } = { merge: true }

      Optional type configuration (defaults to { merge: true })

    Returns PostgrestBuilder<IsValidResultOverride<Result, NewResult, false, false> extends true ? ContainsNull<Result> extends true ? null | MergePartialResult<NewResult, NonNullable<Result>, Options> : MergePartialResult<NewResult, Result, Options> : CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError>

    A PostgrestBuilder instance with the new type

  • returns<NewResult>(): PostgrestBuilder<CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError>
  • Override the type of the returned data.

    deprecated

    Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead

    Type Parameters

    • NewResult

      The new result type to override with

    Returns PostgrestBuilder<CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError>

  • then<TResult1, TResult2>(onfulfilled?: null | ((value: ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>) => TResult1 | PromiseLike<TResult1>), onrejected?: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)): PromiseLike<TResult1 | TResult2>

Generated using TypeDoc