Call a Postgres function
Perform a function call.
You can call Postgres functions as Remote Procedure Calls, logic in your database that you can execute from anywhere. Functions are useful when the logic rarely changes—like for password resets and updates.
create or replace function hello_world() returns text as $$
select 'Hello world';
$$ language sql;
To call Postgres functions on Read Replicas, use the get: true
option.
Parameters
The function name to call
The arguments to pass to the function call
Named parameters
Count algorithm to use to count rows returned by the function. Only applicable for [set-returning functions](https://www.postgresql.org/docs/current/functions-srf.html). `"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.
When set to `true`, the function will be called with read-only access mode.
When set to `true`, `data` will not be returned. Useful if you only need the count.
const { data, error } = await supabase.rpc('hello_world')