Skip to content

suggest to use URL constructor in pg-pool readme #3073

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

komachi
Copy link

@komachi komachi commented Oct 5, 2023

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

@charmander
Copy link
Collaborator

I’m not sure why this is documented this way in the first place instead of using the connectionString option…

@usahai
Copy link

usahai commented Nov 2, 2023

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.

@charmander
Copy link
Collaborator

@usahai As I mentioned in the previous comment, use the connectionString pool option to pass a connection string.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants