Skip to content

An example for listening to Logical Replication in Dart (e.g. listen changes in tables) using `postgres` dart package

License

Notifications You must be signed in to change notification settings

osaxma/postgresql-dart-replication-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Listening PostgreSQL Logical Replication

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]
                        }
                }
        ]
    }

Further Readings

About

An example for listening to Logical Replication in Dart (e.g. listen changes in tables) using `postgres` dart package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published