pg-dbh
v1.1.0
Published
PostgreSQL database pool holder
Downloads
2
Readme
pg-dbh
PostgreSQL database pool holder
Connection
const pg = require('pg');
const pgDbhInit = require('pg-dbh');
const connect = { /* ... */ };
const params = { /* ... */ };
const dbh = pgDbhInit(pg, connect, params);
- pg
user selected version of pg package
- connect
the connection use node-postgres module
- params
- logger - log function to output sql requests
- onError - handler function for pool on 'error' event
Use
Full request
const rows = await dbh(async (db) => {
return await db.SelectAll('* FROM users WHERE role=$1', ['user']);
});
Short request
const rows = await dbh.SelectAll('* FROM users WHERE role=$1', ['user']);
Available functions
will be soon