View Source Supabase.PostgREST (supabase_postgrest v0.2.0)
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 returns the result as a JSON-encoded string.
Executes the query and maps the resulting data to a specified schema struct, useful for casting the results to Elixir structs.
Executes 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.
See Supabase.PostgREST.TransformBuilder.returning/2
.
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
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
- Supabase query execution: https://supabase.com/docs/reference/javascript/performing-queries
Executes the query and returns the result as a JSON-encoded string.
Parameters
builder
: The Builder or Builder instance to execute.
Examples
iex> PostgREST.execute_string(builder)
See also
- Supabase query execution and response handling: https://supabase.com/docs/reference/javascript/performing-queries
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
- Supabase query execution and schema casting: https://supabase.com/docs/reference/javascript/performing-queries
Executes 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.schema
: Optional schema module to map the results.
Examples
iex> PostgREST.execute_to_finch_request(builder, User)
See also
- Supabase query execution: https://supabase.com/docs/reference/javascript/performing-queries
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
- Supabase documentation on initializing queries: https://supabase.com/docs/reference/javascript/from
See Supabase.PostgREST.TransformBuilder.returning/2
.
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
schema
: the schema to operate on, default to theSupabase.Client
DB config
Examples
iex> builder = Supabase.PostgREST.from(client, "users")
iex> Supabase.PostgREST.schema(builder, private)
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"}