How to call database function in supabase?
I have created a supbase database function and want to call from refine app, how can I do that? Is there a method in
refine-supabase
data provider or should I use the supabaseClient.rpc('function_name')
method from supabase?4 Replies
sensitive-blueβ’2y ago
refine-supabase
don't have implementations for functions. of course you can use supabaseClientoptimistic-goldOPβ’2y ago
Ok thank you @alicanerdurmaz
foreign-sapphireβ’2y ago
Hey @dipbazz, just saw this thread. I was thinking about how can we support the functions for supabase the other day π
I thought maybe we can look for a metadata property in
custom
method so we can use them through useCustom
and useCustomMutation
π€
Do you have any ideas on this? Maybe a better way to make them available through refine? I donβt have much experience on the supabase functions and thought maybe you can help πoptimistic-goldOPβ’2y ago
Hey @aliemirs, I am also scratching the surface of supabase but what I know is database function has the power to compute the complex database operation on database level. Those functions either returns the response or not. We can perform multiple tables joins and return the data after computing our business logic and so on.
As you have have mentioned may be we can use
useCustom
and take a parameters as (resource, method, payload, headers)
to hit the endpoint. We may implement it similar to refine-simple-rest
as
So in that way may be we can pass a method as function and call the rpc
method from supabaseClient. I am not sure if this is the correct way to implement the function. But just a idea on using custom hook.