# pg-sugar

> Sugar on top of pg

Latest version **0.0.2** (published 2013-10-26) · 0 weekly downloads

## Install

```sh
npm install pg-sugar
pnpm add pg-sugar
yarn add pg-sugar
bun add pg-sugar
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2013-10-26 |
| First published | 2013-10-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | connrs |
| Maintainers | connrs |

## Links

- npm: https://www.npmjs.com/package/pg-sugar
- Repository: https://github.com/connrs/node-pg-sugar
- Issues: https://github.com/connrs/node-pg-sugar/issues
- npm.io page: https://npm.io/package/pg-sugar

## Recent versions

- 0.0.2 (latest) — 2013-10-26
- 0.0.1 — 2013-10-24

## README

# PG Sugar [![Build Status](https://secure.travis-ci.org/connrs/node-pg-sugar.png?branch=master)](http://travis-ci.org/connrs/node-pg-sugar)

A couple of methods to automate pooling with `pg`.

Create sugar

    var sugar = require('pg-sugar');
    var s = sugar(pg, connectionString);

Create a client to perform a query

    s.client(function (err, query) {
      query('SELECT 1', [], function (err, results) {
        // Do stuff
        // Client is automatically returned to the pool
      });
    });

Create a transaction client to run transactions

    s.transaction(function (err, client) {
      client.query('SELECT 2', [], function (err, results, client) {
        if (err) {
          client.rollback(function () { console.log('LOSE!'); });
        }
        else {
          client.commit(function () { console.log('WIN!'); });
        }
      });
    });

---
_Source: https://npm.io/package/pg-sugar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
