3 ms·
Thanks, this will probably work for me. However, if the inserts are higher, I don't want to get notified that frequently. How would I add a periodic alerts to t
by 120bits 7y ago
Thanks, this will probably work for me. However, if the inserts are higher, I don't want to get notified that frequently. How would I add a periodic alerts to this?
Thank you!
- porsager 7y agoYou could use a column/table to track notifications. Eg. have an alert_sent_at column on the alerts table. Then when the node service receives the notify on an insert you can defer based on any logic you need, and send notifications when needed by a query that fetches alerts with alert_sent_at = null.
- 120bits 7y agoThank you! Thank you so much :)
- porsager 7y agoYou're welcome. To ensure you're not sending alerts twice either select and update in a transaction or use a CTE like: with alert as ( select alert_id from alerts where alert_sent_at is null ) update alerts set alert_sent_at = now() from alert returning *