Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PostgrestQueryBuilder<Schema, Relation, RelationName, Relationships>

Type Parameters

  • Schema extends GenericSchema

  • Relation extends GenericTable | GenericView

  • RelationName = unknown

  • Relationships = Relation extends { Relationships: infer R } ? R : unknown

Hierarchy

  • PostgrestQueryBuilder

Index

Constructors

  • new PostgrestQueryBuilder<Schema, Relation, RelationName, Relationships>(url: URL, __namedParameters: { fetch?: ((input: RequestInfo, init?: RequestInit) => Promise<Response>); headers?: Record<string, string>; schema?: string }): PostgrestQueryBuilder<Schema, Relation, RelationName, Relationships>
  • Type Parameters

    • Schema extends GenericSchema

    • Relation extends GenericTable | GenericView

    • RelationName = unknown

    • Relationships = Relation extends { Relationships: R } ? R : unknown

    Parameters

    • url: URL
    • __namedParameters: { fetch?: ((input: RequestInfo, init?: RequestInit) => Promise<Response>); headers?: Record<string, string>; schema?: string }
      • Optional fetch?: ((input: RequestInfo, init?: RequestInit) => Promise<Response>)
          • (input: RequestInfo, init?: RequestInit): Promise<Response>
          • Parameters

            • input: RequestInfo
            • Optional init: RequestInit

            Returns Promise<Response>

      • Optional headers?: Record<string, string>
      • Optional schema?: string

    Returns PostgrestQueryBuilder<Schema, Relation, RelationName, Relationships>

Properties

fetch?: ((input: RequestInfo, init?: RequestInit) => Promise<Response>)

Type declaration

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

      • input: RequestInfo
      • Optional init: RequestInit

      Returns Promise<Response>

headers: Record<string, string>
schema?: string
signal?: AbortSignal
url: URL

Methods

  • delete(options?: { count?: "exact" | "planned" | "estimated" }): PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>
  • Perform a DELETE on the table or view.

    By default, deleted rows are not returned. To return it, chain the call with .select() after filters.

    Parameters

    • options: { count?: "exact" | "planned" | "estimated" } = {}

      Named parameters

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

        Count algorithm to use to count deleted rows.

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

    Returns PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>

  • insert<Row>(values: Row, options?: { count?: "exact" | "planned" | "estimated" }): PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>
  • insert<Row>(values: Row[], options?: { count?: "exact" | "planned" | "estimated"; defaultToNull?: boolean }): PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>
  • Perform an INSERT into the table or view.

    By default, inserted rows are not returned. To return it, chain the call with .select().

    Type Parameters

    • Row extends Record<string, unknown>

    Parameters

    • values: Row

      The values to insert. Pass an object to insert a single row or an array to insert multiple rows.

    • Optional options: { count?: "exact" | "planned" | "estimated" }

      Named parameters

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

        Count algorithm to use to count inserted rows.

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

    Returns PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>

  • Perform an INSERT into the table or view.

    By default, inserted rows are not returned. To return it, chain the call with .select().

    Type Parameters

    • Row extends Record<string, unknown>

    Parameters

    • values: Row[]

      The values to insert. Pass an object to insert a single row or an array to insert multiple rows.

    • Optional options: { count?: "exact" | "planned" | "estimated"; defaultToNull?: boolean }

      Named parameters

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

        Count algorithm to use to count inserted rows.

        "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 defaultToNull?: boolean

        Make missing fields default to null. Otherwise, use the default value for the column. Only applies for bulk inserts.

    Returns PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>

  • select<Query, ResultOne>(columns?: Query, options?: { count?: "exact" | "planned" | "estimated"; head?: boolean }): PostgrestFilterBuilder<Schema, Relation["Row"], ResultOne[], RelationName, Relationships>
  • Perform a SELECT query on the table or view.

    Type Parameters

    • Query extends string = "*"

    • ResultOne = UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, Query>

    Parameters

    • Optional columns: Query

      The columns to retrieve, separated by commas. Columns can be renamed when returned with customName:columnName

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

      Named parameters

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

        Count algorithm to use to count rows in the table or view.

        "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 head?: boolean

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

    Returns PostgrestFilterBuilder<Schema, Relation["Row"], ResultOne[], RelationName, Relationships>

  • update<Row>(values: Row, options?: { count?: "exact" | "planned" | "estimated" }): PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>
  • Perform an UPDATE on the table or view.

    By default, updated rows are not returned. To return it, chain the call with .select() after filters.

    Type Parameters

    • Row extends Record<string, unknown>

    Parameters

    • values: Row

      The values to update with

    • options: { count?: "exact" | "planned" | "estimated" } = {}

      Named parameters

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

        Count algorithm to use to count updated rows.

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

    Returns PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>

  • upsert<Row>(values: Row, options?: { count?: "exact" | "planned" | "estimated"; ignoreDuplicates?: boolean; onConflict?: string }): PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>
  • upsert<Row>(values: Row[], options?: { count?: "exact" | "planned" | "estimated"; defaultToNull?: boolean; ignoreDuplicates?: boolean; onConflict?: string }): PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>
  • Perform an UPSERT on the table or view. Depending on the column(s) passed to onConflict, .upsert() allows you to perform the equivalent of .insert() if a row with the corresponding onConflict columns doesn't exist, or if it does exist, perform an alternative action depending on ignoreDuplicates.

    By default, upserted rows are not returned. To return it, chain the call with .select().

    Type Parameters

    • Row extends Record<string, unknown>

    Parameters

    • values: Row

      The values to upsert with. Pass an object to upsert a single row or an array to upsert multiple rows.

    • Optional options: { count?: "exact" | "planned" | "estimated"; ignoreDuplicates?: boolean; onConflict?: string }

      Named parameters

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

        Count algorithm to use to count upserted rows.

        "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 ignoreDuplicates?: boolean

        If true, duplicate rows are ignored. If false, duplicate rows are merged with existing rows.

      • Optional onConflict?: string

        Comma-separated UNIQUE column(s) to specify how duplicate rows are determined. Two rows are duplicates if all the onConflict columns are equal.

    Returns PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>

  • Perform an UPSERT on the table or view. Depending on the column(s) passed to onConflict, .upsert() allows you to perform the equivalent of .insert() if a row with the corresponding onConflict columns doesn't exist, or if it does exist, perform an alternative action depending on ignoreDuplicates.

    By default, upserted rows are not returned. To return it, chain the call with .select().

    Type Parameters

    • Row extends Record<string, unknown>

    Parameters

    • values: Row[]

      The values to upsert with. Pass an object to upsert a single row or an array to upsert multiple rows.

    • Optional options: { count?: "exact" | "planned" | "estimated"; defaultToNull?: boolean; ignoreDuplicates?: boolean; onConflict?: string }

      Named parameters

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

        Count algorithm to use to count upserted rows.

        "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 defaultToNull?: boolean

        Make missing fields default to null. Otherwise, use the default value for the column. This only applies when inserting new rows, not when merging with existing rows under ignoreDuplicates: false. This also only applies when doing bulk upserts.

      • Optional ignoreDuplicates?: boolean

        If true, duplicate rows are ignored. If false, duplicate rows are merged with existing rows.

      • Optional onConflict?: string

        Comma-separated UNIQUE column(s) to specify how duplicate rows are determined. Two rows are duplicates if all the onConflict columns are equal.

    Returns PostgrestFilterBuilder<Schema, Relation["Row"], null, RelationName, Relationships>

Generated using TypeDoc