4 ms·
Postgres can do a form of pub/sub with triggers on table change events, pg_notify. For anything more complicated get Postgres to publish all its changes using C
by cormacrelf 5y ago
Postgres can do a form of pub/sub with triggers on table change events, pg_notify. For anything more complicated get Postgres to publish all its changes using Change Data Capture to a Materialize instance. With Materialize, every query can push live updates to an app server, whenever the results change. Debounce a little and push the html, ideally don’t overwrite something the user is editing.
The Materialize folks made a blog post/demo of the materialize->app server->browser pipeline in Python+JS you could follow along with. They have a Postgres CDC implementation too, so hook it all up and it will go.
https://materialize.com/a-simple-and-efficient-real-time-application-powered-by-materializes-tail-command/ https://materialize.com/a-simple-and-efficient-real-time-app... (the images are 404 though)
https://materialize.com/docs/guides/cdc-postgres/ https://materialize.com/docs/guides/cdc-postgres/