Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages