Supabase.PostgREST (supabase_postgrest v1.0.1)

View Source

Provides a suite of functions to interact with a Supabase PostgREST API, allowing for construction and execution of queries using a fluent interface. This module is designed to facilitate the building of complex queries and their execution in the context of a Supabase database application.

For detailed usage examples and more information, refer to the official Supabase documentation: https://supabase.com/docs

Summary

Functions

Executes the query built using the Builder instance and returns the result.

Executes the query and maps the resulting data to a specified schema struct, useful for casting the results to Elixir structs.

Builds a query using the Finch HTTP client, formatting the request appropriately. Returns the HTTP request without executing it.

Initializes a Builder for a specified table and client.

Select a schema to query or perform an function (rpc) call. The schema needs to be on the list of exposed schemas inside Supabase.

Overrides the default media type accept header, which can control the represation of the PostgREST response

Functions

all_of(arg_1, arg_2)

See Supabase.PostgREST.FilterBuilder.all_of/2.

all_of(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.all_of/3.

any_of(arg_1, arg_2)

See Supabase.PostgREST.FilterBuilder.any_of/2.

any_of(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.any_of/3.

contained_by(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.contained_by/3.

contains(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.contains/3.

csv(arg_1)

See Supabase.PostgREST.TransformBuilder.csv/1.

delete(arg_1)

See Supabase.PostgREST.QueryBuilder.delete/1.

delete(arg_1, arg_2)

See Supabase.PostgREST.QueryBuilder.delete/2.

eq(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.eq/3.

execute(b)

Executes the query built using the Builder instance and returns the result.

Parameters

  • builder: The Builder or Builder instance to execute.

Examples

iex> PostgREST.execute(builder)

See also

execute_to(b, schema)

Executes the query and maps the resulting data to a specified schema struct, useful for casting the results to Elixir structs.

Parameters

  • builder: The Builder or Builder instance to execute.
  • schema: The Elixir module representing the schema to which the results should be cast.

Examples

iex> PostgREST.execute_to(builder, User)

See also

execute_to_finch_request(b)

Builds a query using the Finch HTTP client, formatting the request appropriately. Returns the HTTP request without executing it.

Parameters

  • builder: The Builder or Builder instance to execute.

Examples

iex> PostgREST.execute_to_finch_request(builder)

See also

explain(arg_1)

See Supabase.PostgREST.TransformBuilder.explain/1.

explain(arg_1, arg_2)

See Supabase.PostgREST.TransformBuilder.explain/2.

filter(arg_1, arg_2, arg_3, arg_4)

See Supabase.PostgREST.FilterBuilder.filter/4.

from(client, table)

Initializes a Builder for a specified table and client.

Parameters

  • client: The Supabase client used for authentication and configuration.
  • table: The database relation name as a string.

Examples

iex> PostgREST.from(client, "users")
%Builder{}

See also

geojson(arg_1)

See Supabase.PostgREST.TransformBuilder.geojson/1.

gt(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.gt/3.

gte(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.gte/3.

ilike(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.ilike/3.

ilike_all_of(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.ilike_all_of/3.

ilike_any_of(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.ilike_any_of/3.

insert(arg_1, arg_2)

See Supabase.PostgREST.QueryBuilder.insert/2.

insert(arg_1, arg_2, arg_3)

See Supabase.PostgREST.QueryBuilder.insert/3.

is(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.is/3.

like(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.like/3.

like_all_of(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.like_all_of/3.

like_any_of(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.like_any_of/3.

limit(arg_1, arg_2)

See Supabase.PostgREST.TransformBuilder.limit/2.

limit(arg_1, arg_2, arg_3)

See Supabase.PostgREST.TransformBuilder.limit/3.

lt(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.lt/3.

lte(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.lte/3.

match(arg_1, arg_2)

See Supabase.PostgREST.FilterBuilder.match/2.

maybe_single(arg_1)

See Supabase.PostgREST.TransformBuilder.maybe_single/1.

negate(arg_1, arg_2, arg_3, arg_4)

See Supabase.PostgREST.FilterBuilder.negate/4.

neq(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.neq/3.

order(arg_1, arg_2)

See Supabase.PostgREST.TransformBuilder.order/2.

order(arg_1, arg_2, arg_3)

See Supabase.PostgREST.TransformBuilder.order/3.

overlaps(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.overlaps/3.

range(arg_1, arg_2, arg_3)

See Supabase.PostgREST.TransformBuilder.range/3.

range(arg_1, arg_2, arg_3, arg_4)

See Supabase.PostgREST.TransformBuilder.range/4.

range_adjacent(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.range_adjacent/3.

range_gt(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.range_gt/3.

range_gte(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.range_gte/3.

range_lt(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.range_lt/3.

range_lte(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.range_lte/3.

returning(arg_1)

See Supabase.PostgREST.TransformBuilder.returning/1.

returning(arg_1, arg_2)

See Supabase.PostgREST.TransformBuilder.returning/2.

rollback(arg_1)

See Supabase.PostgREST.TransformBuilder.rollback/1.

rpc(client, function, args \\ %{}, opts \\ [])

Perform a function call.

This function returns a Supabase.Fetcher.Request builder that can be safely pipelined to Supabase.PostgREST.FilterBuilder functions.

Params

  • client: The Supabase.Client to perform the function call.
  • fn: The function name to call.
  • args: The arguments to pass to the function call as a map.
  • options: Named parameters:
    • options.head: When set to true, data will not be returned. Useful if you only need the count.
    • options.get: When set to true, the function will be called with read-only access mode.
    • options.count: Count algorithm to use to count rows returned by the function. Only applicable for set-returning functions.
      • "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(b, schema)

Select a schema to query or perform an function (rpc) call. The schema needs to be on the list of exposed schemas inside Supabase.

Parameters

Examples

iex> builder = Supabase.PostgREST.from(client, "users")
iex> Supabase.PostgREST.schema(builder, private)

select(arg_1, arg_2)

See Supabase.PostgREST.QueryBuilder.select/2.

select(arg_1, arg_2, arg_3)

See Supabase.PostgREST.QueryBuilder.select/3.

single(arg_1)

See Supabase.PostgREST.TransformBuilder.single/1.

text_search(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.text_search/3.

text_search(arg_1, arg_2, arg_3, arg_4)

See Supabase.PostgREST.FilterBuilder.text_search/4.

update(arg_1, arg_2)

See Supabase.PostgREST.QueryBuilder.update/2.

update(arg_1, arg_2, arg_3)

See Supabase.PostgREST.QueryBuilder.update/3.

upsert(arg_1, arg_2)

See Supabase.PostgREST.QueryBuilder.upsert/2.

upsert(arg_1, arg_2, arg_3)

See Supabase.PostgREST.QueryBuilder.upsert/3.

with_custom_media_type(b, media_type)

Overrides the default media type accept header, which can control the represation of the PostgREST response

Examples

iex> q = PostgREST.from(client, "users")
iex> q = PostgREST.with_custom_media_type(q, :csv)
iex> PostgREST.execute(q)
{:ok, "id,name

1,john 2,maria"}

See also

within(arg_1, arg_2, arg_3)

See Supabase.PostgREST.FilterBuilder.within/3.