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

PostgrestClient

PostgREST client.

class PostgrestClient<Database = any, ClientOptions extends ClientServerOptions = GetGenericDatabaseWithOptions<Database, {
PostgrestVersion: "12";
}
>
["options"]
, SchemaName extends string & keyof GetGenericDatabaseWithOptions<Database>["db"] = "public" extends keyof GetGenericDatabaseWithOptions<Database>["db"] ? "public" : string & keyof GetGenericDatabaseWithOptions<Database>["db"], Schema extends GenericSchema = GetGenericDatabaseWithOptions<Database>["db"][SchemaName] extends GenericSchema ? GetGenericDatabaseWithOptions<Database>["db"][SchemaName] : any>
{
constructor(url: string, { headers, schema, fetch }?: {
headers?: HeadersInit;
schema?: SchemaName;
fetch?: Fetch;
}
);
fetch?: Fetch;
headers: Headers;
schemaName?: SchemaName;
url: string;
 
from<TableName extends string & keyof Schema["Tables"], Table extends Schema["Tables"][TableName]>(relation: TableName): PostgrestQueryBuilder<ClientOptions, Schema, Table, TableName>;
from<ViewName extends string & keyof Schema["Views"], View extends Schema["Views"][ViewName]>(relation: ViewName): PostgrestQueryBuilder<ClientOptions, Schema, View, ViewName>;
rpc<FnName extends string & keyof Schema["Functions"], Fn extends Schema["Functions"][FnName]>(
fn: FnName,
args?: Fn["Args"],
{ head, get, count }?: {
head?: boolean;
get?: boolean;
count?: "exact" | "planned" | "estimated";
}
,
): PostgrestFilterBuilder<ClientOptions, Schema, Fn["Returns"] extends any[] ? Fn["Returns"][number] extends Record<string, unknown> ? Fn["Returns"][number] : never : never, Fn["Returns"], FnName, null, "RPC">;
schema<DynamicSchema extends string & keyof GetGenericDatabaseWithOptions<Database>["db"]>(schema: DynamicSchema): PostgrestClient<Database, ClientOptions, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any>;
}

§Type Parameters

§
Database = any
[src]
§
ClientOptions extends ClientServerOptions = GetGenericDatabaseWithOptions<Database, {
PostgrestVersion: "12";
}
>
["options"]
[src]
§
SchemaName extends string & keyof GetGenericDatabaseWithOptions<Database>["db"] = "public" extends keyof GetGenericDatabaseWithOptions<Database>["db"] ? "public" : string & keyof GetGenericDatabaseWithOptions<Database>["db"]
[src]
§
Schema extends GenericSchema = GetGenericDatabaseWithOptions<Database>["db"][SchemaName] extends GenericSchema ? GetGenericDatabaseWithOptions<Database>["db"][SchemaName] : any
[src]

§Constructors

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

Creates a PostgREST client.

@param url
  • URL of the PostgREST endpoint
@param options
  • Named parameters
@param options.headers
  • Custom headers
@param options.schema
  • Postgres schema to switch to
@param options.fetch
  • Custom fetch

§Properties

§
fetch: Fetch
[src]
§
headers: Headers
[src]
§
schemaName: SchemaName
[src]
§
url: string
[src]

§Methods

§
from<TableName extends string & keyof Schema["Tables"], Table extends Schema["Tables"][TableName]>(relation: TableName): PostgrestQueryBuilder<ClientOptions, Schema, Table, TableName>
[src]
from<ViewName extends string & keyof Schema["Views"], View extends Schema["Views"][ViewName]>(relation: ViewName): PostgrestQueryBuilder<ClientOptions, Schema, View, ViewName>
[src]
§
rpc<FnName extends string & keyof Schema["Functions"], Fn extends Schema["Functions"][FnName]>(fn: FnName, args?: Fn["Args"], { head, get, count }?: {
head?: boolean;
get?: boolean;
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<ClientOptions, Schema, Fn["Returns"] extends any[] ? Fn["Returns"][number] extends Record<string, unknown> ? Fn["Returns"][number] : never : never, Fn["Returns"], FnName, null, "RPC">
[src]

Perform a function call.

@param fn
  • The function name to call
@param args
  • The arguments to pass to the function call
@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.get
  • When set to true, the function will be called with read-only access mode.
@param options.count

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

§
schema<DynamicSchema extends string & keyof GetGenericDatabaseWithOptions<Database>["db"]>(schema: DynamicSchema): PostgrestClient<Database, ClientOptions, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any>
[src]

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

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

@param schema
  • The schema to query