Skip to main content

initPostgres

function initPostgres(config: Object)

Initializes a PostgreSQL connection pool using pg.Pool.

Returns: Pool

  • PostgreSQL connection pool instance.
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
configObjectPostgreSQL configuration options.
See the official pg package documentation for more details:
config.connectionStringstringConnection string for PostgreSQL.

Throws:

Will log an error and exit the process if the connection string is missing or the connection fails.
See:

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