initPostgres
function initPostgres(config: Object)
Initializes a PostgreSQL connection pool using pg.Pool
.
Returns: Pool
- PostgreSQL connection pool instance.
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
config | Object | PostgreSQL configuration options. See the official pg package documentation for more details: | ||
config.connectionString | string | Connection 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" });