JavaScript: rpc
Perform a function call.
Parameters
fn
(Required)The function name to call
args
(Required)The arguments to pass to the function call
options
(Required)Named parameters
Examples
Example 1
// For cross-schema functions where type inference fails, use overrideTypes:
const { data } = await supabase
.schema('schema_b')
.rpc('function_a', {})
.overrideTypes<{ id: string; user_id: string }[]>()
Call a Postgres function without arguments
const { data, error } = await supabase.rpc('hello_world')
Call a Postgres function with arguments
const { data, error } = await supabase.rpc('echo', { say: 'ð' })
Bulk processing
const { data, error } = await supabase.rpc('add_one_each', { arr: [1, 2, 3] })
Call a Postgres function with filters
const { data, error } = await supabase
.rpc('list_stored_countries')
.eq('id', 1)
.single()
Call a read-only Postgres function
const { data, error } = await supabase.rpc('hello_world', undefined, { get: true })
