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

PostgrestTransformBuilder

import { PostgrestTransformBuilder } from "https://esm.sh/@supabase/postgrest-js@2.99.3/dist/index.d.mts";
class PostgrestTransformBuilder<ClientOptions extends ClientServerOptions, Schema extends GenericSchema, Row extends Record<string, unknown>, Result$1, RelationName = unknown, Relationships = unknown, Method = unknown> extends PostgrestBuilder<ClientOptions, Result$1> {
abortSignal(signal: AbortSignal): this;
csv(): PostgrestBuilder<ClientOptions, string>;
explain({ analyze, verbose, settings, buffers, wal, format }?: {
analyze?: boolean;
verbose?: boolean;
settings?: boolean;
buffers?: boolean;
wal?: boolean;
format?: "json" | "text";
}
): PostgrestBuilder<ClientOptions, Record<string, unknown>[], false> | PostgrestBuilder<ClientOptions, string, false>;
geojson(): PostgrestBuilder<ClientOptions, Record<string, unknown>>;
limit(count: number, { foreignTable, referencedTable }?: {
foreignTable?: string;
referencedTable?: string;
}
): this;
maxAffected(value: number): MaxAffectedEnabled<ClientOptions["PostgrestVersion"]> extends true ? Method extends "PATCH" | "DELETE" | "RPC" ? this : InvalidMethodError<"maxAffected method only available on update or delete"> : InvalidMethodError<"maxAffected method only available on postgrest 13+">;
maybeSingle<ResultOne = (Result$1 extends (infer ResultOne)[] ? ResultOne : never)>(): PostgrestBuilder<ClientOptions, ResultOne | null>;
order<ColumnName extends string & keyof Row>(column: ColumnName, options?: {
ascending?: boolean;
nullsFirst?: boolean;
referencedTable?: undefined;
}
): this;
order(column: string, options?: {
ascending?: boolean;
nullsFirst?: boolean;
referencedTable?: string;
}
): this;
order<ColumnName extends string & keyof Row>(column: ColumnName, options?: {
ascending?: boolean;
nullsFirst?: boolean;
foreignTable?: undefined;
}
): this;
order(column: string, options?: {
ascending?: boolean;
nullsFirst?: boolean;
foreignTable?: string;
}
): this;
range(
from: number,
to: number,
{ foreignTable, referencedTable }?: {
foreignTable?: string;
referencedTable?: string;
}
,
): this;
returns<NewResult>(): PostgrestTransformBuilder<ClientOptions, Schema, Row, CheckMatchingArrayTypes<Result$1, NewResult>, RelationName, Relationships, Method>;
rollback(): this;
select<Query extends string = "*", NewResultOne = GetResult<Schema, Row, RelationName, Relationships, Query, ClientOptions>>(columns?: Query): PostgrestFilterBuilder<ClientOptions, Schema, Row, Method extends "RPC" ? Result$1 extends unknown[] ? NewResultOne[] : NewResultOne : NewResultOne[], RelationName, Relationships, Method>;
single<ResultOne = (Result$1 extends (infer ResultOne)[] ? ResultOne : never)>(): PostgrestBuilder<ClientOptions, ResultOne>;
}

§Type Parameters

§
ClientOptions extends ClientServerOptions
[src]
§
Schema extends GenericSchema
[src]
§
Row extends Record<string, unknown>
[src]
§
Result$1
[src]
§
RelationName = unknown
[src]
§
Relationships = unknown
[src]
§
Method = unknown
[src]

§Extends

§
PostgrestBuilder<ClientOptions, Result$1>
[src]

§Methods

§
abortSignal(signal: AbortSignal): this
[src]

Set the AbortSignal for the fetch request.

@param signal
  • The AbortSignal to use for the fetch request
@example
@example

Aborting requests in-flight

const ac = new AbortController()

const { data, error } = await supabase
  .from('very_big_table')
  .select()
  .abortSignal(ac.signal)

// Abort the request after 100 ms
setTimeout(() => ac.abort(), 100)
@example
@example

Set a timeout

const { data, error } = await supabase
  .from('very_big_table')
  .select()
  .abortSignal(AbortSignal.timeout(1000 /* ms *\/))
@example
§
csv(): PostgrestBuilder<ClientOptions, string>
[src]

Return data as a string in CSV format.

@example
@example

Return data as CSV

const { data, error } = await supabase
  .from('characters')
  .select()
  .csv()
@example
@example
§
explain({ analyze, verbose, settings, buffers, wal, format }?: {
analyze?: boolean;
verbose?: boolean;
settings?: boolean;
buffers?: boolean;
wal?: boolean;
format?: "json" | "text";
}
): PostgrestBuilder<ClientOptions, Record<string, unknown>[], false> | PostgrestBuilder<ClientOptions, string, false>
[src]

Return data as the EXPLAIN plan for the query.

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

@param options
  • Named parameters
@param options.analyze
  • If true, the query will be executed and the actual run time will be returned
@param options.verbose
  • If true, the query identifier will be returned and data will include the output columns of the query
@param options.settings
  • If true, include information on configuration parameters that affect query planning
@param options.buffers
  • If true, include information on buffer usage
@param options.wal
  • If true, include information on WAL record generation
@param options.format
  • The format of the output, can be "text" (default) or "json"
@example
@example

Get the execution plan

const { data, error } = await supabase
  .from('characters')
  .select()
  .explain()
@example
@example
@example
@example

Get the execution plan with analyze and verbose

const { data, error } = await supabase
  .from('characters')
  .select()
  .explain({analyze:true,verbose:true})
@example
@example
§
geojson(): PostgrestBuilder<ClientOptions, Record<string, unknown>>
[src]

Return data as an object in GeoJSON format.

§
limit(count: number, { foreignTable, referencedTable }?: {
foreignTable?: string;
referencedTable?: string;
}
): this
[src]

Limit the query result by count.

@param count
  • The maximum number of rows to return
@param options
  • Named parameters
@param options.referencedTable
  • Set this to limit rows of referenced tables instead of the parent table
@param options.foreignTable
  • Deprecated, use options.referencedTable instead
@example

With select()

const { data, error } = await supabase
  .from('characters')
  .select('name')
  .limit(1)
@example
@example
@example

On a referenced table

const { data, error } = await supabase
  .from('orchestral_sections')
  .select(`
    name,
    instruments (
      name
    )
  `)
  .limit(1, { referencedTable: 'instruments' })
@example
@example
§
maxAffected(value: number): MaxAffectedEnabled<ClientOptions["PostgrestVersion"]> extends true ? Method extends "PATCH" | "DELETE" | "RPC" ? this : InvalidMethodError<"maxAffected method only available on update or delete"> : InvalidMethodError<"maxAffected method only available on postgrest 13+">
[src]

Set the maximum number of rows that can be affected by the query. Only available in PostgREST v13+ and only works with PATCH and DELETE methods.

@param value
  • The maximum number of rows that can be affected
§
maybeSingle<ResultOne = (Result$1 extends (infer ResultOne)[] ? ResultOne : never)>(): PostgrestBuilder<ClientOptions, ResultOne | null>
[src]

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.

@example

With select()

const { data, error } = await supabase
  .from('characters')
  .select()
  .eq('name', 'Katniss')
  .maybeSingle()
@example
@example
§
order<ColumnName extends string & keyof Row>(column: ColumnName, options?: {
ascending?: boolean;
nullsFirst?: boolean;
referencedTable?: undefined;
}
): this
[src]
order(column: string, options?: {
ascending?: boolean;
nullsFirst?: boolean;
referencedTable?: string;
}
): this
[src]
order<ColumnName extends string & keyof Row>(column: ColumnName, options?: {
ascending?: boolean;
nullsFirst?: boolean;
foreignTable?: undefined;
}
): this deprecated
[src]
@deprecated

Use options.referencedTable instead of options.foreignTable

order(column: string, options?: {
ascending?: boolean;
nullsFirst?: boolean;
foreignTable?: string;
}
): this deprecated
[src]
@deprecated

Use options.referencedTable instead of options.foreignTable

§
range(from: number, to: number, { foreignTable, referencedTable }?: {
foreignTable?: string;
referencedTable?: string;
}
): this
[src]

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.

@param from
  • The starting index from which to limit the result
@param to
  • The last index to which to limit the result
@param options
  • Named parameters
@param options.referencedTable
  • Set this to limit rows of referenced tables instead of the parent table
@param options.foreignTable
  • Deprecated, use options.referencedTable instead
@example

With select()

const { data, error } = await supabase
  .from('characters')
  .select('name')
  .range(0, 1)
@example
@example
§
returns<NewResult>(): PostgrestTransformBuilder<ClientOptions, Schema, Row, CheckMatchingArrayTypes<Result$1, NewResult>, RelationName, Relationships, Method> deprecated
[src]

Override the type of the returned data.

@deprecated

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

@example

Override type of successful response

const { data } = await supabase
  .from('countries')
  .select()
  .returns<Array<MyType>>()
@example
@example

Override type of object response

const { data } = await supabase
  .from('countries')
  .select()
  .maybeSingle()
  .returns<MyType>()
@example
§
rollback(): this
[src]

Rollback the query.

data will still be returned, but the query is not committed.

§
select<Query extends string = "*", NewResultOne = GetResult<Schema, Row, RelationName, Relationships, Query, ClientOptions>>(columns?: Query): PostgrestFilterBuilder<ClientOptions, Schema, Row, Method extends "RPC" ? Result$1 extends unknown[] ? NewResultOne[] : NewResultOne : NewResultOne[], RelationName, Relationships, Method>
[src]

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.

@param columns
  • The columns to retrieve, separated by commas
@example

With upsert()

const { data, error } = await supabase
  .from('characters')
  .upsert({ id: 1, name: 'Han Solo' })
  .select()
@example
@example
§
single<ResultOne = (Result$1 extends (infer ResultOne)[] ? ResultOne : never)>(): PostgrestBuilder<ClientOptions, ResultOne>
[src]

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.

@example

With select()

const { data, error } = await supabase
  .from('characters')
  .select('name')
  .limit(1)
  .single()
@example
@example