Watches your PostgreSQL DB for changes. Before using this module you need to set up some triggers, for example with postgres-triggers.
Heavily inspired by this blog post by @fritzy.
This module is in its early stages. Feedback and PRs welcome!
Install
npm i postgres-watcher
Usage (API)
This module is basically an event emitter. It doesn't make any assumption about your trigger payload, except that it should be a JSON object.
const Watcher = const watcher = // listen for changeswatcher watcher // start watching, callback is optionalwatcherstart { if err throw err console // true} // insert, update, delete rows in your db... // stop watching, callback is optionalwatcher
TODO
there is certainly stuff to do ;-)
Tests
You need to give it a database connection string to be able to run the tests.
POSTGRES=postgres://postgres@localhost:5432/postgres npm test
License
MIT