Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access pg client events? #103

Open
uLan08 opened this issue Jul 25, 2017 · 3 comments
Open

Access pg client events? #103

uLan08 opened this issue Jul 25, 2017 · 3 comments

Comments

@uLan08
Copy link
Contributor

uLan08 commented Jul 25, 2017

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.

@uLan08
Copy link
Contributor Author

uLan08 commented Jul 26, 2017

I just utilized another package for this specific feature.

@uLan08 uLan08 closed this as completed Jul 26, 2017
@langpavel
Copy link
Owner

Sorry @uLan08, quite late, which one? :-)

@langpavel langpavel reopened this Aug 30, 2017
@uLan08
Copy link
Contributor Author

uLan08 commented Aug 31, 2017

It's this one https://github.com/voxpelli/node-pg-pubsub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants