Looking for clarification on some concepts: We hav...
# help
d
Looking for clarification on some concepts: We have Triggers, Functions, Function Hooks, and Edge Functions. I thought Functions Hooks were basically triggers? but then what are
Triggers
? And It seems like
Functions
are postgres RPC functions, but then what are Edge Functions?
n
Hello @DanMossa! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
d
To me, it seems like Functions Hooks should be used if I need to call an external api.
Where as triggers are for manipulating things inside of postgres?
And then functions are RPC for postgres, but Edge Functions are also for external
Function Hooks and Edge Functions are for external. Triggers and Functions are Postgres. ?
n
Function Hooks are basically "Triggers" that can trigger something outside of the Database, for example an HTTP Request
Whereas a normal Trigger can trigger a function stored within the database
g
Function hooks are basically triggers with a function that use pg_net to do an async http call. They are fixed format though (the row). I assume shortly they will also call edge functions directly. You can do the same thing with a trigger and postgres function which does sql and then use pgsql-http to make formatted calls, but is not as elegant as pg-net (which you could also call on your own) but I've never tried it. Postgres functions can be called by rpc or by triggers and are really the same thing just the input is defined as new/old record in the trigger function. Edge functions are javascript functions that run independently of the database and can make calls to the SB APIs (database/storage/auth), or not use Supabase at all in their code. They are like lite weight Google Cloud or AWS Lambda functions. I say lite weight because they only do javascript and memory and time restrictions are tighter.
d
Very well said. Thank you both
n
Thread was archived by @DanMossa. Anyone can send a message to unarchive it.