Socket
Book a DemoInstallSign in
Socket

pg-ts

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-ts

Typescript wrapper around node-postgres

latest
Source
npmnpm
Version
2.5.1
Version published
Maintainers
2
Created
Source

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

FAQs

Package last updated on 26 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts