pg-subscribe
subscribe to postgres events via postgresql notify/listen
this is a fork of pg-pub-sub to address some open issues, provide 1st class typescript support, and improve the api.
install
npm install pg-subscribe --save
usage
basic
var subscriber = 'postgres://username@localhost/database'await subscriberawait subscriber
the above sends NOTIFY channelName, '{"hello":"world"}'
to PostgreSQL, which will trigger the above listener with the parsed JSON in channelPayload
.
advanced
var subscriber = 'postgres://username@localhost/database'await subscriber// subscriber is a full EventEmitter object that sends events on channel namessubscriber
api
a copy of the latest typings can always be found here