I have a table I am watching but cannot receive the notifications, the body is always empty.
My worker.js:
scServer.on('connection', function (socket) {
pg.connect(connectionString, function(err, client) {
if(err) {
console.log(err);
}
client.on('notification', function(msg) {
console.log(msg);
// emit
socket.exchange.publish('updates_selections,', msg);
});
var query = client.query("LISTEN updates_selections");
});
});
});
The console shows:
Message {
name: 'notification',
length: 28,
processId: 29189,
channel: 'updates_selections',
payload: '' }
The procedure (gets triggered fine on update and insert but either no data gets passed or the pg client doesn't get it)
CREATE or replace FUNCTION notify_trigger() RETURNS trigger AS $$
DECLARE
BEGIN
PERFORM pg_notify('updates_selections', 'id' || NEW.id||'price'|| NEW.price|| 'status'|| NEW.status|| 'name'|| NEW.name ||'type'|| TG_OP );
RETURN new;
END;
$$ LANGUAGE plpgsql;
I am using postgres 9.2 and can't upgrade yet in order to use json_build_object btw.
What am I doing wrong?
via Nick M
No comments:
Post a Comment