suggest to use URL constructor in pg-pool readme
improve example with parsing connection string for pg-pool, use URL constructor, available since node 10
https://developer.mozilla.org/en-US/docs/Web/API/URL/URL
I’m not sure why this is documented this way in the first place instead of using the connectionString option…
Is there a way to extend the client for pooled connections? I need to use a schema, but the existing type definitions does not accept a schema, unless I pass it in as a part of the URL in the client. However, it's not extensible to pooled connections.
So this is fine for client -
const client: ClientConfig = new Client(
process.env.DB_URL,
// {
// host: process.env.DB_HOST,
// port: process.env.DB_PORT as unknown as number,
// database: process.env.DB_DATABASE,
// user: process.env.DB_USER,
// password: process.env.DB_PASSWORD,
// }
)
And I was thinking maybe if there was a provision to do something like this -
const pool: Pool = new Pool({
...client,
max: 20,
idleTimeoutMillis: 60000,
connectionTimeoutMillis: 20000,
})
wherein the URL will get deconstructed on it's own (overly hopeful, I know) OR
const pool: Pool = new Pool(client, {
max: 20,
idleTimeoutMillis: 60000,
connectionTimeoutMillis: 20000,
})
where the additional parameters get attached to the Pool object.
@usahai As I mentioned in the previous comment, use the connectionString pool option to pass a connection string.