Skip to main content

initPostgres

function initPostgres(config: Object = {})
async

Initializes a PostgreSQL connection pool using pg.Pool.

Returns: Promise<Object>

  • Resolves to a PostgreSQL connection pool instance.
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
configObject✔️PostgreSQL configuration options.
See the official pg package documentation for more details:
config.connectionStringstringConnection string for PostgreSQL.
config.poolConfigObject✔️Additional pg.Pool configuration options.

Throws: Error

Rejects if config.connectionString is missing or the connection fails.
See:

const pool = await initPostgres({ connectionString: "postgres://user:pass@localhost:5432/mydb" });