pg-live-table
v1.2.2
Published
Real time monitoring of Postgres database table
Downloads
8
Maintainers
Readme
pg-live-table: Postgres live monitoring
A javascript library to monitor in real time Postgresql database table.
Install
$ npm install --save pg-live-table
Usage
import PgLiveTable from 'pg-live-table';
let dbUrl = 'postgres://username:password@localhost/database';
let liveTable = PgLiveTable({dbUrl: dbUrl);
let ee = await liveTable.monitor('mytable');
ee.on('insert', (payload) => {
console.log(`GOT insert: data: ${payload.data}`);
})
.on('update', (payload) => {
let {old_data, new_data} = payload;
console.log(`GOT update: old: ${old_data}, new: ${new_data}`);
})
.on('delete', (payload) => {
console.log(`GOT delete: data: ${payload.data}`);
});
await liveTable.listen();
//When done, don't forget to call liveTable.close()
Test
Make sure Postgres is running locally before running the test
$ npm test
License
MIT © Frederic Heem