Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>

Type Parameters

  • Schema extends GenericSchema

  • Row extends Record<string, unknown>

  • Result

  • RelationName = unknown

  • Relationships = unknown

Hierarchy

Index

Constructors

Properties

body?: unknown
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>
isMaybeSingle: boolean
method: "GET" | "HEAD" | "POST" | "PATCH" | "DELETE"
schema?: string
shouldThrowOnError: boolean = false
signal?: AbortSignal
url: URL

Methods

  • explain(options?: { analyze?: boolean; buffers?: boolean; format?: "json" | "text"; settings?: boolean; verbose?: boolean; wal?: boolean }): PostgrestBuilder<string> | PostgrestBuilder<Record<string, unknown>[]>
  • Return data as the EXPLAIN plan for the query.

    You need to enable the db_plan_enabled setting before using this method.

    Parameters

    • options: { analyze?: boolean; buffers?: boolean; format?: "json" | "text"; settings?: boolean; verbose?: boolean; wal?: boolean } = {}

      Named parameters

      • Optional analyze?: boolean

        If true, the query will be executed and the actual run time will be returned

      • Optional buffers?: boolean

        If true, include information on buffer usage

      • Optional format?: "json" | "text"

        The format of the output, can be "text" (default) or "json"

      • Optional settings?: boolean

        If true, include information on configuration parameters that affect query planning

      • Optional verbose?: boolean

        If true, the query identifier will be returned and data will include the output columns of the query

      • Optional wal?: boolean

        If true, include information on WAL record generation

    Returns PostgrestBuilder<string> | PostgrestBuilder<Record<string, unknown>[]>

  • limit(count: number, options?: { foreignTable?: string; referencedTable?: string }): PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>
  • Limit the query result by count.

    Parameters

    • count: number

      The maximum number of rows to return

    • options: { foreignTable?: string; referencedTable?: string } = {}

      Named parameters

      • Optional foreignTable?: string

        Deprecated, use options.referencedTable instead

      • Optional referencedTable?: string

        Set this to limit rows of referenced tables instead of the parent table

    Returns PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>

  • Return data as a single object instead of an array of objects.

    Query result must be zero or one row (e.g. using .limit(1)), otherwise this returns an error.

    Type Parameters

    • ResultOne = Result extends ResultOne[] ? ResultOne : never

    Returns PostgrestBuilder<null | ResultOne>

  • order<ColumnName>(column: ColumnName, options?: { ascending?: boolean; nullsFirst?: boolean; referencedTable?: undefined }): PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>
  • order(column: string, options?: { ascending?: boolean; nullsFirst?: boolean; referencedTable?: string }): PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>
  • order<ColumnName>(column: ColumnName, options?: { ascending?: boolean; foreignTable?: undefined; nullsFirst?: boolean }): PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>
  • order(column: string, options?: { ascending?: boolean; foreignTable?: string; nullsFirst?: boolean }): PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>
  • Order the query result by column.

    You can call this method multiple times to order by multiple columns.

    You can order referenced tables, but it only affects the ordering of the parent table if you use !inner in the query.

    Type Parameters

    • ColumnName extends string

    Parameters

    • column: ColumnName

      The column to order by

    • Optional options: { ascending?: boolean; nullsFirst?: boolean; referencedTable?: undefined }

      Named parameters

      • Optional ascending?: boolean

        If true, the result will be in ascending order

      • Optional nullsFirst?: boolean

        If true, nulls appear first. If false, nulls appear last.

      • Optional referencedTable?: undefined

        Set this to order a referenced table by its columns

    Returns PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>

  • Order the query result by column.

    You can call this method multiple times to order by multiple columns.

    You can order referenced tables, but it only affects the ordering of the parent table if you use !inner in the query.

    Parameters

    • column: string

      The column to order by

    • Optional options: { ascending?: boolean; nullsFirst?: boolean; referencedTable?: string }

      Named parameters

      • Optional ascending?: boolean

        If true, the result will be in ascending order

      • Optional nullsFirst?: boolean

        If true, nulls appear first. If false, nulls appear last.

      • Optional referencedTable?: string

        Set this to order a referenced table by its columns

    Returns PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>

  • Order the query result by column.

    You can call this method multiple times to order by multiple columns.

    You can order referenced tables, but it only affects the ordering of the parent table if you use !inner in the query.

    deprecated

    Use options.referencedTable instead of options.foreignTable

    Type Parameters

    • ColumnName extends string

    Parameters

    • column: ColumnName

      The column to order by

    • Optional options: { ascending?: boolean; foreignTable?: undefined; nullsFirst?: boolean }

      Named parameters

      • Optional ascending?: boolean
      • Optional foreignTable?: undefined
      • Optional nullsFirst?: boolean

    Returns PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>

  • Order the query result by column.

    You can call this method multiple times to order by multiple columns.

    You can order referenced tables, but it only affects the ordering of the parent table if you use !inner in the query.

    deprecated

    Use options.referencedTable instead of options.foreignTable

    Parameters

    • column: string

      The column to order by

    • Optional options: { ascending?: boolean; foreignTable?: string; nullsFirst?: boolean }

      Named parameters

      • Optional ascending?: boolean
      • Optional foreignTable?: string
      • Optional nullsFirst?: boolean

    Returns PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>

  • range(from: number, to: number, options?: { foreignTable?: string; referencedTable?: string }): PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>
  • Limit the query result by starting at an offset from and ending at the offset to. Only records within this range are returned. This respects the query order and if there is no order clause the range could behave unexpectedly. The from and to values are 0-based and inclusive: range(1, 3) will include the second, third and fourth rows of the query.

    Parameters

    • from: number

      The starting index from which to limit the result

    • to: number

      The last index to which to limit the result

    • options: { foreignTable?: string; referencedTable?: string } = {}

      Named parameters

      • Optional foreignTable?: string

        Deprecated, use options.referencedTable instead

      • Optional referencedTable?: string

        Set this to limit rows of referenced tables instead of the parent table

    Returns PostgrestTransformBuilder<Schema, Row, Result, RelationName, Relationships>

  • select<Query, NewResultOne>(columns?: Query): PostgrestTransformBuilder<Schema, Row, NewResultOne[], RelationName, Relationships>
  • Perform a SELECT on the query result.

    By default, .insert(), .update(), .upsert(), and .delete() do not return modified rows. By calling this method, modified rows are returned in data.

    Type Parameters

    • Query extends string = "*"

    • NewResultOne = GetResult<Schema, Row, RelationName, Relationships, Query>

    Parameters

    • Optional columns: Query

      The columns to retrieve, separated by commas

    Returns PostgrestTransformBuilder<Schema, Row, NewResultOne[], RelationName, Relationships>

  • Return data as a single object instead of an array of objects.

    Query result must be one row (e.g. using .limit(1)), otherwise this returns an error.

    Type Parameters

    • ResultOne = Result extends ResultOne[] ? ResultOne : never

    Returns PostgrestBuilder<ResultOne>

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

Generated using TypeDoc