async queryApi (text, params, res, cb = null, options = null) {
    await pool.query(text, params)
      .then(async (result) => {
        if (cb) {
          let stopCb

          if (options) {
            if (options.atLeastOneRow && result.rowCount <= 0) {
              res.status(204).send({ message: 'Query result is empty' })
              stopCb = true
            }
          }

          if (!stopCb) {
            await cb(result)
          }
        }
      })
      .catch(e => res.status(500).send(e))
      .finally(() => res.end())
  }
/**
   * Query DB for Express APIs. Auto handles errors.
   * @param {string} text Query text
   * @param {any[]} params Query parameters
   * @param {Response} res Express response
   * @param {(result) => void} cb Callback if query succeed and meet conditions from `options`
   * @param {{}} options Extra options to check before invoking callback
   */
Query DB for Express APIs. Auto handles errors.
Query DB for Express APIs . Auto handles errors .
async queryApi (text, params, res, cb = null, options = null) {
    await pool.query(text, params)
      .then(async (result) => {
        if (cb) {
          let stopCb
          if (options) {
            if (options.atLeastOneRow && result.rowCount <= 0) {
              res.status(204).send({ message: 'Query result is empty' })
              stopCb = true
            }
          }
          if (!stopCb) {
            await cb(result)
          }
        }
      })
      .catch(e => res.status(500).send(e))
      .finally(() => res.end())
  }
async queryApi ( text , params , res , cb = null , options = null ) { await pool . query ( text , params ) . then ( async ( result ) => { if ( cb ) { let stopCb if ( options ) { if ( options . atLeastOneRow && result . rowCount <= 0 ) { res . status ( 204 ) . send ( { message : 'Query result is empty' } ) stopCb = true } } if ( ! stopCb ) { await cb ( result ) } } } ) . catch ( e => res . status ( 500 ) . send ( e ) ) . finally ( ( ) => res . end ( ) ) }
Query DB for Express APIs.
Query DB for Express APIs .