postgres/client.js
function connect() {
  log('debug', `Connecting to Postgres at ${POSTGRES_HOST}:${POSTGRES_PORT}`);

  knex = knexLib({
    client: 'pg',
    connection: {
      host: POSTGRES_HOST,
      user: POSTGRES_USER,
      password: POSTGRES_PASSWORD,
      database: POSTGRES_DB,
      port: POSTGRES_PORT
    },
    pool: { min: CONNECTION_POOL_MIN, max: CONNECTION_POOL_MAX }
  });

  // TODO: improve error catch! https://github.com/clay/amphora-storage-postgres/pull/7/files/16d3429767943a593ad9667b0d471fefc15088d3#diff-6a1e11a6146d3a5a01f955a44a2ac07a
  return knex.table('information_schema.tables').first()
    .catch(createDBIfNotExists);
}
function connect() {
  log('debug', `Connecting to Postgres at ${POSTGRES_HOST}:${POSTGRES_PORT}`);

  knex = knexLib({
    client: 'pg',
    connection: {
      host: POSTGRES_HOST,
      user: POSTGRES_USER,
      password: POSTGRES_PASSWORD,
      database: POSTGRES_DB,
      port: POSTGRES_PORT
    },
    pool: { min: CONNECTION_POOL_MIN, max: CONNECTION_POOL_MAX }
  });

  // TODO: improve error catch! https://github.com/clay/amphora-storage-postgres/pull/7/files/16d3429767943a593ad9667b0d471fefc15088d3#diff-6a1e11a6146d3a5a01f955a44a2ac07a
  return knex.table('information_schema.tables').first()
    .catch(createDBIfNotExists);
}
function connect ( ) { log ( 'debug' , ` ${ POSTGRES_HOST } ${ POSTGRES_PORT } ` ) ; knex = knexLib ( { client : 'pg' , connection : { host : POSTGRES_HOST , user : POSTGRES_USER , password : POSTGRES_PASSWORD , database : POSTGRES_DB , port : POSTGRES_PORT } , pool : { min : CONNECTION_POOL_MIN , max : CONNECTION_POOL_MAX } } ) ; // TODO: improve error catch! https://github.com/clay/amphora-storage-postgres/pull/7/files/16d3429767943a593ad9667b0d471fefc15088d3#diff-6a1e11a6146d3a5a01f955a44a2ac07a return knex . table ( 'information_schema.tables' ) . first ( ) . catch ( createDBIfNotExists ) ; }
Connect to the DB. We need to do a quick check
to see if we're actually connected to the Clay
DB. If we aren't, connect to default and then
use that connection to create the Clay DB.

@returns {Promise}
Connect to the DB . We need to do a quick check to see if we re actually connected to the Clay DB . If we aren t connect to default and then use that connection to create the Clay DB .