I have some code thats works Ok in PHP. From the postgres CLI I issue a
NOTIFY job;
The notification is correctly raised by Postgres ( I can see it in the PHP client), but can't read it in node.
JS:
var pg = require('pg');
var conString = "your postgres information";
var client = new pg.Client(conString);
client.connect();
client.query('LISTEN job');
client.on('notification', function(msg) {
console.log('data');
});
I would prefer to keep it simple. Is the only way to make a procedure in postgres like this?
Ok, the problem was in the conString parameter.
var conString = "tcp://user:pass@localhost/db";
Is important to check that you are using the correct database to reach the notification messages.