vitaly-t/pg-monitor

output not showing up in console

milne-dev opened this issue · 7 comments

Here is the code I am using to initialize pg-monitor:

    // postgres setup
    const pg_options = {
        host: 'localhost',
        port: 5432,
        database: 'test',
        user: 'dm',
        password: 'asdfasdf'
    };

    global.db = pgp(pg_options);

    // postgres monitoring
    require("pg-monitor").attach(pg_options);

Is there something that I am doing wrong?

Is there something that I am doing wrong?

yes, please follow the example and the API.

pg-monitor is to be attached to pg-promise initialization options object, not the connection object.

I tried passing in an empty object but that didn't work either:

require("pg-monitor").attach({});

to init pg-promise I do not pass an object to use default settings.

now my code is like:

    const pgp = require('pg-promise')();
    // postgres setup
    const pg_options = {
        host: 'localhost',
        port: 5432,
        database: 'test',
        user: 'dm',
        password: 'asdfasdf'
    };

    global.db = pgp(pg_options);
    require("pg-monitor").attach({});

As per the example, you have to pass in an options object into pg-promise, if you are to use pg-monitor.

ahhh okay, I will try this. Thank you for your help!

Did you get it sorted? :)

Yes I did as your last comment cleared things up for me.
I just want to say thanks for making pg-promise a great library! The documentation is very detailed and it makes using pg very easy to use without having to deal with the connection pool and constant error checking in nested callbacks.

You are welcome! :)