Я использую узел postgres, который будет вставлять данные в таблицу postgresql после прослушивания уведомления
У меня есть следующий код
#! /app/bin/node
var pg = require('pg');
const datar = async function () {
var conString = "postgresql://postgres:root@localhost:5432/postgres"
var client = await new pg.Client(conString);
await client.connect(function(err) {
if(err) {
return console.error('could not connect to postgres', err);
}
// client.on('notification', function(data) {
// console.log(data.payload);
// //client.end();
// });
//client.connect();
client.query('LISTEN "data_channel"', [], (err,data) => {
if (err) {
console.log(err);
} else {
console.log('DATA:', data);
}
client.end();
});
});
}
datar();
Он не LISTEN каналу и не возвращает
DATA: Result {
command: 'LISTEN',
rowCount: null,
oid: null,
rows: [],
fields: [],
_parsers: [],
RowCtor: null,
rowAsArray: false,
_getTypeParser: [Function: bound ] }
Но когда я СЛУШАЮ канал, используя команду psql, я могу найти полезную нагрузку данных в консоли psql.
Но в узле js это не происходит, и я также попытался пойматьвсе еще безуспешно.
Любая помощь будет действительно ощутимой