pg-ts
TypeScript icon, indicating that this package has built-in type declarations

2.5.1 • Public • Published

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();

Dependencies (4)

Dev Dependencies (9)

Package Sidebar

Install

npm i pg-ts

Weekly Downloads

59

Version

2.5.1

License

MIT

Unpacked Size

284 kB

Total Files

73

Last publish

Collaborators

  • musicglue-admin
  • nikcorg