pg-ts

v8.1.0
Typescript wrapper around node-postgres

pg-ts

Typescript wrapper around node-postgres

Installing

yarn add pg-ts

Using

Using promises:

import getPool, { SQL } from "pg-ts";

const pool = getPool();
const { firstName, lastName } = person;

pool.transaction(tx =>
  Promise
    .all([
      tx.none(SQL`INSERT INTO people (first_name, last_name) VALUES (${firstName}, ${lastName}))`),
      tx.one(SQL`SELECT * FROM people WHERE first_name = ${firstName})`),
    ])
    .then(([,person]) => person));

Using fp-ts Tasks:

import getPool, { SQL } from "pg-ts";

const pool = getPool();

pool.oneTask(SQL`SELECT * FROM people WHERE first_name = ${firstName})`).run();

Metadata

  • MIT
  • Whatever
  • Music Glue
  • released 10/3/2018

Downloads

Maintainers