postgresHandler
function postgresHandler(pool: Pool, text: string, params: Array = [], callback: function)
async
Executes a PostgreSQL query using the provided connection pool.
Returns: Promise<Object>
- Query result object.
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
pool | Pool | PostgreSQL connection pool instance. | ||
text | string | SQL query string. | ||
params | Array | ✔️ | [] | Query parameters. |
callback | function | ✔️ | Optional callback function. |
const result = await postgresHandler(pool, "SELECT * FROM users WHERE id = $1", [1]);
console.log(result.rows);