Is there any way i can use postgres triggers to tr...
# off-topic
m
Is there any way i can use postgres triggers to trigger an edge function? The workflow i have currently in my app is that my function is living inside a container and listening to insert events in a specific table via realtime. Can i simply migrate that function to a supabase edge function and then use a postgres trigger to run it?
I was thinking that a last resort may be to just deploy the function and then have a postgres function call the edge function api endpoint, and then have the postgres function be triggered by the postgres trigger. This seems like a hacky workaround though.
g
I assume at some point they will add the function hooks to call it directly. Until then you would have to use the http request or the http extension.
m
I see. Thanks
I have tried the HTTP request method but it seems to me that my function is not getting the data in the request body.
If i have the hook on 'INSERT' how can i access the newly inserted data?
j
You will need to add a header to your function hook to trigger an edge function currently.
Authorization
:
Bearer [your anon key]
We will update function hooks (which will be renamed to Async Triggers) so that you simply just have to select the edge function and you won't need to add any urls or headers
there should be some data in the request body, that seems odd
m
I think i will stick to my current architecture for now, of running the functions in dedicated docker containers as that also simplifies the self hosting aspect. I will give another look to functions later this year, maybe in August.
For now, this is my Bachelor's Thesis peoject and the deadline is kinda closing in :)))
I am, however, very excited to implement functions in my projects! Keep up the great work!