Skip to content

Access pg client events? #103

@uLan08

Description

@uLan08

I am trying to implement pg NOTIFY , LISTEN and I saw this example.

var pg = require ('pg'),    
    pgConnectionString = "postgres://user:pass@localhost/db"; 
var client = new pg.Client(pgConnectionString);
client.connect();
client.query('LISTEN "article_watcher"');
client.on('notification', function(data) {    console.log(data.payload);});

Is this possible using this package?

I tried doing

const pg = new PgAsync(uri)
// create schema, trigger functions code
pg.connect((client) => {
	client.on('notification', (msg) => {
                console.log(JSON.parse(msg.payload))
	})
})

But it's just giving out errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions