Class PostgrestClient<Database, ClientOptions, SchemaName, Schema>

PostgREST client.

Type Parameters

  • Database = any

    Types for the schema from the type generator

  • ClientOptions extends PostgrestClientOptions = Database extends {
        __InternalSupabase: infer I extends PostgrestClientOptions;
    } ? I : {}

  • SchemaName extends string & keyof Omit<Database, "__InternalSupabase"> = "public" extends keyof Omit<Database, "__InternalSupabase"> ? "public" : string & keyof Omit<Database, "__InternalSupabase">

    Postgres schema to switch to. Must be a string literal, the same one passed to the constructor. If the schema is not "public", this must be supplied manually.

  • Schema extends GenericSchema = Omit<Database, "__InternalSupabase">[SchemaName] extends GenericSchema ? Omit<Database, "__InternalSupabase">[SchemaName] : any

Hierarchy

  • PostgrestClient

Constructors

Properties

Methods

Constructors

  • Creates a PostgREST client.

    Type Parameters

    • Database = any

    • ClientOptions extends PostgrestClientOptions = Database extends {
          __InternalSupabase: I;
      } ? I : {}

    • SchemaName extends string = "public" extends Exclude<keyof Database, "__InternalSupabase"> ? "public" : string & Exclude<keyof Database, "__InternalSupabase">

    • Schema extends GenericSchema = Omit<Database, "__InternalSupabase">[SchemaName] extends GenericSchema ? any[any] : any

    Parameters

    • url: string

      URL of the PostgREST endpoint

    • options: {
          fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>);
          headers?: HeadersInit;
          schema?: SchemaName;
      } = {}

      Named parameters

      • Optional fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)
          • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
          • Custom fetch

            Parameters

            • input: RequestInfo | URL
            • Optional init: RequestInit

            Returns Promise<Response>

      • Optional headers?: HeadersInit

        Custom headers

      • Optional schema?: SchemaName

        Postgres schema to switch to

    Returns PostgrestClient<Database, ClientOptions, SchemaName, Schema>

Properties

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: Headers
schemaName?: SchemaName
url: string

Methods

  • Perform a query on a table or a view.

    Type Parameters

    • TableName extends string

    • Table extends GenericTable

    Parameters

    • relation: TableName

      The table or view name to query

    Returns PostgrestQueryBuilder<ClientOptions, Schema, Table, TableName, Table extends {
        Relationships: R;
    } ? R : unknown>

  • Perform a query on a table or a view.

    Type Parameters

    • ViewName extends string

    • View extends GenericView

    Parameters

    • relation: ViewName

      The table or view name to query

    Returns PostgrestQueryBuilder<ClientOptions, Schema, View, ViewName, View extends {
        Relationships: R;
    } ? R : unknown>

  • Perform a function call.

    Type Parameters

    • FnName extends string

    • Fn extends GenericFunction

    Parameters

    • fn: FnName

      The function name to call

    • args: Fn["Args"] = {}

      The arguments to pass to the function call

    • options: {
          count?: "exact" | "planned" | "estimated";
          get?: boolean;
          head?: boolean;
      } = {}

      Named parameters

      • Optional count?: "exact" | "planned" | "estimated"

        Count algorithm to use to count rows returned by the function. Only applicable for set-returning functions.

        "exact": Exact but slow count algorithm. Performs a COUNT(*) under the hood.

        "planned": Approximated but fast count algorithm. Uses the Postgres statistics under the hood.

        "estimated": Uses exact count for low numbers and planned count for high numbers.

      • Optional get?: boolean

        When set to true, the function will be called with read-only access mode.

      • Optional head?: boolean

        When set to true, data will not be returned. Useful if you only need the count.

    Returns PostgrestFilterBuilder<ClientOptions, Schema, Fn["Returns"] extends any[] ? any[any][number] extends Record<string, unknown> ? any[any] : never : never, Fn["Returns"], FnName, null, "RPC">

  • Select a schema to query or perform an function (rpc) call.

    The schema needs to be on the list of exposed schemas inside Supabase.

    Type Parameters

    • DynamicSchema extends string

    Parameters

    • schema: DynamicSchema

      The schema to query

    Returns PostgrestClient<Database, ClientOptions, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? any[any] : any>

Generated using TypeDoc