From b7d542a5b76fba74a2ed0fe0e435feec87881ade Mon Sep 17 00:00:00 2001 From: Daven Quinn Date: Sat, 25 May 2024 20:02:03 -0500 Subject: [PATCH] Created a fairly hacky solution to allow referencing multiple databases on the same cluster --- v2/larkin.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/v2/larkin.js b/v2/larkin.js index 1a659592..f61e27c5 100644 --- a/v2/larkin.js +++ b/v2/larkin.js @@ -31,7 +31,15 @@ var mysql = require("mysql"), const nameMapping = credentials.postgresDatabases ?? {} const dbName = nameMapping[db] ?? db - const pool = new pg.Pool({connectionString: credentials.pg.connectionString}); + // Hacky way to get the connection string for a specific database on the same cluster. + // This will need to be revisited to create a separate environment variable for each expected database. + const connString = credentials.pg.connectionString + + let prefix = connString.split('/').slice(0, -1).join('/') + const connectionString = `${prefix}/${dbName}` + + + const pool = new pg.Pool({connectionString}); pool.connect(function(err, client, done) { if (err) {