Skip to content

Commit

Permalink
fix: make transport chainable
Browse files Browse the repository at this point in the history
  • Loading branch information
Xstoudi committed Mar 2, 2020
1 parent 19edb92 commit 2347883
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ function transporter(errConfig: string | null, config: PinoPgConfig) {
if(errConfig !== null) return console.error(errConfig)

const pgTransport = through.obj((chunk, encoding, callback) => {
console.log(chunk)
const client = new Client(config.connection)
client.connect((connectErr) => {
if(connectErr !== null) {
console.error(connectErr)
return callback('Failed to connect to PostgreSQL server.')
}

client.query(buildInsertString(config), Object.values(JSON.parse(chunk)), (queryErr, result) => {
if(queryErr !== null) {
console.error(queryErr)
Expand Down

0 comments on commit 2347883

Please sign in to comment.