# postgres-wrapper

> Postgres simple wrapper

Latest version **1.0.4** (published 2020-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install postgres-wrapper
pnpm add postgres-wrapper
yarn add postgres-wrapper
bun add postgres-wrapper
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-04-08 |
| First published | 2020-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Stanislau Karaban |
| Maintainers | stasandk |
| Keywords | pg, npm, postgres, simple, wrapper |

## Links

- npm: https://www.npmjs.com/package/postgres-wrapper
- Repository: https://github.com/stasandk/postgres-wrapper
- Homepage: https://github.com/stasandk/postgres-wrapper#readme
- Issues: https://github.com/stasandk/postgres-wrapper/issues
- npm.io page: https://npm.io/package/postgres-wrapper

## Dependencies (1)

- [pg](https://npm.io/package/pg.md) ^7.18.2

## Recent versions

- 1.0.4 (latest) — 2020-04-08
- 1.0.3 — 2020-03-17
- 1.0.2 — 2020-03-16
- 1.0.1 — 2020-03-16
- 1.0.0 — 2020-03-16
- 0.0.1 — 2020-03-16

## README

# postgres-wrapper

Postgres simple wrapper service.

## Install

```
$ npm install postgres-wrapper
```

## Usage

Before use you need to set environment variables:
 - NODE_ENV (Node environment: development, production, etc..)
 - POSTGRES_URL (Url to connnecto to postgres: postgres://username:password@url:port/db)

```js
const pg = require('postgres-wrapper')

// Get one record from db
async function run () {
  const id = 1
  const query = `
    SELECT *
    FROM data
    WHERE id = $1`
  const params = [id]
  const object = await pg.one({ query, params }) // return one record in object
  const object = await pg.oneOrNone({ query, params }) // return one or none record
  const array = await pg.any({ query, params }) // return one or many record in array
  const array = await pg.many({ query, params }) // return many records in array
  await pg.none({ query, params }) // no returning any record
  await pg.end() // end postgress connection
}

run()
```

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