This repo contains an example under the example folder for listening to Postgresql Logical Replication using the dart postgres
package (pub | repo) -- version 2.5.0 or above. This allows listening to changes in PostgreSQL database in the following manner:
-
Insert changes (one row):
{ "change": [ { "kind": "insert", "schema": "public", "table": "temp", "columnnames": ["id", "val"], "columntypes": ["integer", "text"], "columnvalues": [58, "new value"] } ] }
-
Update changes (two rows):
{ "change": [ { "kind": "update", "schema": "public", "table": "temp", "columnnames": ["id", "val"], "columntypes": ["integer", "text"], "columnvalues": [2, "updated value"], "oldkeys": { "keynames": ["id"], "keytypes": ["integer"], "keyvalues": [2] } } ,{ "kind": "update", "schema": "public", "table": "temp", "columnnames": ["id", "val"], "columntypes": ["integer", "text"], "columnvalues": [1, "updated value"], "oldkeys": { "keynames": ["id"], "keytypes": ["integer"], "keyvalues": [1] } } ] }
-
Delete changes (one row):
{ "change": [ { "kind": "delete", "schema": "public", "table": "temp", "oldkeys": { "keynames": ["id"], "keytypes": ["integer"], "keyvalues": [51] } } ] }
- Frontend Backend Protocol -- the chapter covering both Replication and Extended Query Protocols.
- Streaming Replication Protocol
- Logical Replication Message Formats
- Protocol Message Format