lib/worker.js
function (connectionInfo, query, params) {
    var connection,
        client = new pg.Client(connectionInfo);

    client.connect(function (err) {
        if (err) {
            return respond({
                success: false,
                data: {
                    err: err,
                    query: query,
                    connection: connectionInfo
                }
            });
        }

        // execute a query on our database
        client.query(query, params, function (err, result) {
            // close the client
            client.end();

            // treat the error
            if (err) {
                return respond({
                    success: false,
                    data: {
                        err: err,
                        query: query,
                        connection: connectionInfo
                    }
                });
            }
            
            // Return the respose
            return respond({
                success: true,
                data: result
            });
        });
    });
}
function (connectionInfo, query, params) {
    var connection,
        client = new pg.Client(connectionInfo);

    client.connect(function (err) {
        if (err) {
            return respond({
                success: false,
                data: {
                    err: err,
                    query: query,
                    connection: connectionInfo
                }
            });
        }

        // execute a query on our database
        client.query(query, params, function (err, result) {
            // close the client
            client.end();

            // treat the error
            if (err) {
                return respond({
                    success: false,
                    data: {
                        err: err,
                        query: query,
                        connection: connectionInfo
                    }
                });
            }
            
            // Return the respose
            return respond({
                success: true,
                data: result
            });
        });
    });
}
function ( connectionInfo , query , params ) { var connection , client = new pg . Client ( connectionInfo ) ; client . connect ( function ( err ) { if ( err ) { return respond ( { success : false , data : { err : err , query : query , connection : connectionInfo } } ) ; } // execute a query on our database client . query ( query , params , function ( err , result ) { // close the client client . end ( ) ; // treat the error if ( err ) { return respond ( { success : false , data : { err : err , query : query , connection : connectionInfo } } ) ; } // Return the respose return respond ( { success : true , data : result } ) ; } ) ; } ) ; }
Execute postresql query
@param   {object} connectionInfo Object containing information about the connection
@param   {string} query          The query to execute
@param   {Array}  params         Params to use in the query
@returns {mixed}  Void
Execute postresql query