new DbPool(options, defaults)
- Description:
Create a new database pool with default methods and properties
Parameters:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | an object with default pool properties, see Pool Properties
|
||||||||||||||||||
defaults |
object | an object with default pool methods for init and shutdown and other properties The db methods cover most use cases but in case native driver needs to be used this is how to get the client and use it with its native API,
it is required to call |
Example
var pool = db.getPool("pg");
pool.use((err, client) => {
client.query("SELECT * from users", (err, rows) => {
pool.release(client);
});
});
// Or async version
const { client } = await pool.ause((err);
const { err, rows, info } = await client.aquery("SELECT * from users");
pool.release(client);