{"id":19268560,"url":"https://github.com/qweeze/pg_watcher","last_synced_at":"2025-02-23T19:46:24.985Z","repository":{"id":98775459,"uuid":"319696112","full_name":"qweeze/pg_watcher","owner":"qweeze","description":"A set of PL/pgSQL functions to monitor changes in result of an arbitrary SQL query","archived":false,"fork":false,"pushed_at":"2020-12-08T17:11:40.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-05T12:41:53.473Z","etag":null,"topics":["pgsql","postgresql"],"latest_commit_sha":null,"homepage":"","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qweeze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-08T16:27:32.000Z","updated_at":"2020-12-08T17:11:42.000Z","dependencies_parsed_at":"2023-05-25T07:15:44.319Z","dependency_job_id":null,"html_url":"https://github.com/qweeze/pg_watcher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qweeze%2Fpg_watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qweeze%2Fpg_watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qweeze%2Fpg_watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qweeze%2Fpg_watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qweeze","download_url":"https://codeload.github.com/qweeze/pg_watcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240371742,"owners_count":19790888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pgsql","postgresql"],"created_at":"2024-11-09T20:16:42.430Z","updated_at":"2025-02-23T19:46:24.948Z","avatar_url":"https://github.com/qweeze.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"### pg_watcher\n\nA set of PL/pgSQL functions to monitor data changes (CDC) as a result of an arbitrary SQL query\n\nChanges are computed by comparing result of a query against a materialized view based on the same query. A query must have `_id` column which is used to join it with the materialized view.\n\n##### Usage example:\n\n```sql\ntest=# CREATE TABLE books (_id SERIAL, title TEXT, author TEXT);\nCREATE TABLE\n\ntest=# SELECT watcher.add_query('myquery', 'select * from books');\n-[ RECORD 1 ]\nadd_query |\n\ntest=# INSERT INTO books (title) VALUES ('The Very Hungry Caterpillar');\nINSERT 0 1\n\ntest=# --We have 1 insert (operation = 'I') after query was added for watching\ntest=# SELECT * FROM watcher.get_changes('myquery');\n-[ RECORD 1 ]--------------------------------------------------------\nidentifier | 1\noperation  | I\nold_values |\nnew_values | {\"title\": \"The Very Hungry Caterpillar\", \"author\": null}\nchange_id  | 1\n\ntest=# --Mark changes as read\ntest=# SELECT watcher.reset_changes('myquery');\n-[ RECORD 1 ]-+-\nreset_changes |\n\ntest=# SELECT * FROM watcher.get_changes('myquery');\n(0 rows)\n\ntest=# UPDATE books SET title = 'New title' where _id = 1;\nUPDATE 1\n\ntest=# SELECT * FROM watcher.get_changes('myquery');\n-[ RECORD 1 ]--------------------------------------------------------\nidentifier | 1\noperation  | U\nold_values | {\"title\": \"The Very Hungry Caterpillar\", \"author\": null}\nnew_values | {\"title\": \"New title\", \"author\": null}\nchange_id  | 2\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqweeze%2Fpg_watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqweeze%2Fpg_watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqweeze%2Fpg_watcher/lists"}