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;
let value: String = try await supabase
.rpc("hello_world")
.execute()
.value
let response: String = try await supabase
.rpc("echo", params: ["say": "đź‘‹"])
.execute()
.value
let response: [Int] = try await supabase
.rpc("add_one_each", params: ["arr": [1, 2, 3]])
.execute()
.value
struct Country: Decodable \{
let id: Int
let name: String
\}
let country: Country = await supabase
.rpc("list_stored_countries")
.eq("id", value: 1)
.single()
.execute()
.value