initPostgres
function initPostgres(config: Object = {})
async
Initializes a PostgreSQL connection pool using pg.Pool.
Returns: Promise<Object>
- Resolves to a 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. | ||
| config.poolConfig | Object | ✔️ | 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" });