@macrostrat/pg-helper

2.0.0 • Public • Published

pg-helper

Boilerplate for working with Postgres in Node

Installation

npm install --save @macrostrat/pg-helper

Usage

const pgHelper = require('@macrostrat/pg-helper')

let pg = new pgHelper({
  host: 'localhost',
  user: 'postgres',
  port: 5432,
  database: 'database'
})

pg.query('SELECT pork FROM pig WHERE fatty = $1', [ true ], (error, result) => {
   // result 
})

pg.queryStream('SELECT ice_cream FROM freezer WHERE flavor = $1', [ 'chocolate' ]))
  .pipe(fs.createWriteStream('./treats.txt'))

API

query(sql, params, callback(error, rows))

queryStream(sql, params)

License

MIT

Package Sidebar

Install

npm i @macrostrat/pg-helper

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

4.39 kB

Total Files

5

Last publish

Collaborators

  • idzikowski.casey
  • jczaplew
  • davenquinn