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

PostgrestQueryBuilder

import { PostgrestQueryBuilder } from "https://esm.sh/@supabase/postgrest-js@2.89.0/dist/index.d.mts";
class PostgrestQueryBuilder<ClientOptions extends ClientServerOptions, Schema extends GenericSchema, Relation$1 extends GenericTable | GenericView, RelationName = unknown, Relationships = (Relation$1 extends {
Relationships: infer R;
}
? R : unknown
)
>
{
constructor(url: URL, { headers, schema, fetch }: {
headers?: HeadersInit;
schema?: string;
fetch?: Fetch;
}
);
fetch?: Fetch;
headers: Headers;
schema?: string;
signal?: AbortSignal;
url: URL;
 
delete({ count }?: {
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "DELETE">;
insert<Row extends (Relation$1 extends {
Insert: unknown;
}
? Relation$1["Insert"] : never
)
>
(values: Row, options?: {
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "POST">;
insert<Row extends (Relation$1 extends {
Insert: unknown;
}
? Relation$1["Insert"] : never
)
>
(values: Row[], options?: {
count?: "exact" | "planned" | "estimated";
defaultToNull?: boolean;
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "POST">;
select<Query extends string = "*", ResultOne = GetResult<Schema, Relation$1["Row"], RelationName, Relationships, Query, ClientOptions>>(columns?: Query, options?: {
head?: boolean;
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], ResultOne[], RelationName, Relationships, "GET">;
update<Row extends (Relation$1 extends {
Update: unknown;
}
? Relation$1["Update"] : never
)
>
(values: Row, { count }?: {
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "PATCH">;
upsert<Row extends (Relation$1 extends {
Insert: unknown;
}
? Relation$1["Insert"] : never
)
>
(values: Row, options?: {
onConflict?: string;
ignoreDuplicates?: boolean;
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "POST">;
upsert<Row extends (Relation$1 extends {
Insert: unknown;
}
? Relation$1["Insert"] : never
)
>
(values: Row[], options?: {
onConflict?: string;
ignoreDuplicates?: boolean;
count?: "exact" | "planned" | "estimated";
defaultToNull?: boolean;
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "POST">;
}

§Type Parameters

§
ClientOptions extends ClientServerOptions
[src]
§
Schema extends GenericSchema
[src]
§
Relation$1 extends GenericTable | GenericView
[src]
§
RelationName = unknown
[src]
§
Relationships = (Relation$1 extends {
Relationships: infer R;
}
? R : unknown
)
[src]

§Constructors

§
new PostgrestQueryBuilder(url: URL, { headers, schema, fetch }: {
headers?: HeadersInit;
schema?: string;
fetch?: Fetch;
}
)
[src]

Creates a query builder scoped to a Postgres table or view.

@example
import PostgrestQueryBuilder from '@supabase/postgrest-js'

const query = new PostgrestQueryBuilder(
  new URL('https://xyzcompany.supabase.co/rest/v1/users'),
  { headers: { apikey: 'public-anon-key' } }
)

§Properties

§
fetch: Fetch
[src]
§
headers: Headers
[src]
§
schema: string
[src]
§
signal: AbortSignal
[src]
§
url: URL
[src]

§Methods

§
delete({ count }?: {
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "DELETE">
[src]

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.

@param options
  • Named parameters
@param options.count
  • 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.

§
insert<Row extends (Relation$1 extends {
Insert: unknown;
}
? Relation$1["Insert"] : never
)
>
(values: Row, options?: {
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "POST">
[src]
insert<Row extends (Relation$1 extends {
Insert: unknown;
}
? Relation$1["Insert"] : never
)
>
(values: Row[], options?: {
count?: "exact" | "planned" | "estimated";
defaultToNull?: boolean;
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "POST">
[src]
§
select<Query extends string = "*", ResultOne = GetResult<Schema, Relation$1["Row"], RelationName, Relationships, Query, ClientOptions>>(columns?: Query, options?: {
head?: boolean;
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], ResultOne[], RelationName, Relationships, "GET">
[src]

Perform a SELECT query on the table or view.

@param columns
  • The columns to retrieve, separated by commas. Columns can be renamed when returned with customName:columnName
@param options
  • Named parameters
@param options.head
  • When set to true, data will not be returned. Useful if you only need the count.
@param options.count
  • 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.

§
update<Row extends (Relation$1 extends {
Update: unknown;
}
? Relation$1["Update"] : never
)
>
(values: Row, { count }?: {
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "PATCH">
[src]

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.

@param values
  • The values to update with
@param options
  • Named parameters
@param options.count
  • 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.

§
upsert<Row extends (Relation$1 extends {
Insert: unknown;
}
? Relation$1["Insert"] : never
)
>
(values: Row, options?: {
onConflict?: string;
ignoreDuplicates?: boolean;
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "POST">
[src]
upsert<Row extends (Relation$1 extends {
Insert: unknown;
}
? Relation$1["Insert"] : never
)
>
(values: Row[], options?: {
onConflict?: string;
ignoreDuplicates?: boolean;
count?: "exact" | "planned" | "estimated";
defaultToNull?: boolean;
}
): PostgrestFilterBuilder<ClientOptions, Schema, Relation$1["Row"], null, RelationName, Relationships, "POST">
[src]