SupabaseS
Supabase4y ago
Drew

Data Intensive Weekly Cron Job

Each week, I want to select all users in a table, then for each, gather several data points and send an email containing that data. According to this documentation: https://supabase.com/blog/postgres-as-a-cron-server , this is a good fit for a database function on Supabase ("Sending welcome emails. If you use an email provider with an HTTP API, then you batch emails to that service. Write a function that selects all your signups yesterday, then sends them to your favorite transactional email service. Schedule it every day to run at midnight.") Is this the best approach? What's more intuitive to me, as someone not so familiar with SQL and more familiar with JS, is to use a postgress cron function to trigger an edge function. Can you point me to an example of a database function that iterates over a table and makes a query and http request for each row? Is that the superior way to accomplish this?
Supabase
Running repetitive tasks with your Postgres database.
Was this page helpful?