JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q36845F
  • License MIT

postgres database helper

Package Exports

  • node-pg-helper

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-pg-helper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-pg-helper

common helper functions for node-postgres

Examples

const { Pool } = require('pg');

const db = require('node-pg-helper');

const pool = new Pool({ connectionString: process.env.DATABASE_URL, ssl: { rejectUnauthorized: false } });

Set the client as Pool

db.setClient(pool);

(async function() {

example insert

await db.insert('users', {
    'id': 100,
    'firstname': 'john',
    'lastname': 'smith'
})

select all the rows in a table

let rows = await db.selectAllRows("users");

rows.forEach(row => {
    console.log(row);
});

})();