-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hey,
I am just getting familiar with notifications in postgres.
Why can't I just do something like:
const { Client } = require('pg');
const connectionString = process.env.DATABASE_URL;
const client = new Client({ connectionString });
async function listenToNotifications() {
try {
// Connect to Postgres
await client.connect();
// Listen to specific channel in Postgres
// Attach a listener to notifications received
client.on('notification', (msg) => {
console.log('Notification received', msg.payload);
});
await client.query('LISTEN channel_name');
console.log('Listening for notifications on my_channel');
} catch (e) {
console.log(e);
}
}What purpose does this library serve that's not covered by this?
Metadata
Metadata
Assignees
Labels
No labels