# pg-query-string

> build PostgreSQL query strings

Latest version **0.1.7** (published 2020-10-02) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install pg-query-string
pnpm add pg-query-string
yarn add pg-query-string
bun add pg-query-string
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2020-10-02 |
| First published | 2020-09-22 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 191.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dan Lynch |
| Maintainers | pyramation |
| Keywords | postgres, query |

## Links

- npm: https://www.npmjs.com/package/pg-query-string
- Repository: https://github.com/pyramation/sql-query
- Homepage: https://github.com/pyramation/sql-query#readme
- Issues: https://github.com/pyramation/sql-query/issues
- npm.io page: https://npm.io/package/pg-query-string

## Dependencies (2)

- [pg-escape](https://npm.io/package/pg-escape.md) ^0.2.0
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.4.2

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 0.1.7 (latest) — 2020-10-02
- 0.1.6 — 2020-10-02
- 0.1.5 — 2020-10-02
- 0.1.4 — 2020-09-29
- 0.1.3 — 2020-09-29
- 0.1.2 — 2020-09-22
- 0.1.1 — 2020-09-22
- 0.1.0 — 2020-09-22

## README

# pg-query-string [![Build Status](https://travis-ci.org/pyramation/pg-query-string.svg?branch=master)](https://travis-ci.org/pyramation/pg-query-string)

```sh
npm install pg-query-string
```

Thanks to https://github.com/hiddentao/squel

This is essentially squel, however a few changes:

* built with babel instead of gulp
* hard-coded to postgres 
* added type coersions 
* classes handy for testing

```js
import { Table, Schema } from 'pg-query-string';

const schema = new Schema('my-schema');
const table = schema.table('users', {
  id: 'uuid',
  username: 'text',
  email: 'email',
  password: 'password',
  active: 'boolean',
  tags: 'text[]'
});

table.update(
  {
    active: true,
    tags: ['pyramation']
  },
  {
    id: 1
  }
);
```

Which produces the following object

```
Object {
  "text": "UPDATE \\"my-schema\\".users SET active = $1::boolean, tags = ($2::text[]) WHERE (id = $3::uuid)",
  "values": Array [
    true,
    Array [
      "pyramation",
    ],
    1,
  ],
}
```

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