Skip to content

Commit

Permalink
Created a fairly hacky solution to allow referencing multiple databas…
Browse files Browse the repository at this point in the history
…es on the same cluster
  • Loading branch information
davenquinn committed May 26, 2024
1 parent 762e802 commit 8cd5e74
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion v2/larkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8cd5e74

Please sign in to comment.