Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

postgres-bridge

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postgres-bridge

pg compatibility layer for postgres.

Source
npmnpm
Version
1.8.5
Version published
Weekly downloads
484
10.25%
Maintainers
1
Weekly downloads
 
Created
Source

postgres/pg compatibility layer

Canonical Code Style Twitter Follow

Wraps postgres API in a pg compatible API.

Usage

import postgres from 'postgres';
import { createBridge } from 'postgres-bridge';

const PostgresBridge = createBridge(postgres);

// pg.Pool Configuration
const configuration = {
  host: 'localhost',
  user: 'database-user',
  max: 20,
  idleTimeoutMillis: 30000,
  connectionTimeoutMillis: 2000,
};

const pool = new PostgresBridge(configuration);

const connection = await pool.connect();

await pg.query('SELECT $1::text as name', ['foo']);

Motivation

postgres is leaner/faster implementation of PostgreSQL protocol in Node.js than pg. However, postgres API is very different from the more broadly adopted pg client. This package allows to adopt postgres without going through a painful migration. In particular, this compatibility layer has been designed to allow adoption of postgres using Slonik PostgreSQL client.

Scope

postgres-bridge is limited to the API that is consumed by Slonik PostgreSQL client, i.e. Using postgres-bridge you are able to use postgres with Slonik.

Supported features:

  • pool.connect
  • connection.query
  • connect event
  • notice event

Known incompatibilities:

  • connection.processID not implemented
  • pool._pulseQueue not implemented

Please submit PR if you require additional compatibility.

Development

Running postgres-bridge tests requires having a local PostgreSQL instance.

The easiest way to setup a temporary instance for testing is using Docker, e.g.

docker run --rm -it -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 postgres

Keywords

postgres

FAQs

Package last updated on 02 Aug 2022

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