1.0.0 • Published 5 years ago

@bamsfaas/pg-connection-wrapper v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Usage

const {useClient} = require('pg-connection-wrapper')

const dbConfig = // Get database config such as access credentials

async function accessDatabase() {
    const result = await useClient(dbConfig, client => {
        // Access database via client
        return ...
    })
    // Use result
}

Replaces

const dbConfig = // Get database config such as access credentials

async function accessDatabase() {
    const client = new Client(dbConfig)
    await client.connect()
    try {
        // Access database via client
        const result = ...
        // Use result
    } finally {
        client.end()
    }
}

Look up documentation of 'pg' npm package to see details about database config and client objects.

1.0.0

5 years ago