JCKalt / General-Work

Modeling database
0 stars 0 forks source link

pgui database io - improve connection pool sharing #174

Closed JCKalt closed 6 months ago

JCKalt commented 6 months ago

pgui api table updates were coded to create connection objects in code: src/pages/api/table/update/[table].js

// PostgreSQL connection pool const pool = new Pool({ host: process.env.PGHOST_3, user: process.env.PGUSER_3, database: process.env.PGDATABASE_3, port: process.env.PGPORT_3, });

However this work is also done here but for the Eyedro DB, but better because it turns off SSL which we need until we add certificate usage.

src/lib/db.js

const connectionOptions = { host: process.env.PGHOST_2, port: process.env.PGPORT_2, database: process.env.PGDATABASE_2, user: process.env.PGUSER_2, };

if (baseUrl.startsWith('https')) { connectionOptions.ssl = { rejectUnauthorized: false }; }

Look for ways to share this among update, insert and delete crud ops.