Skip to content

Pure JavaScript client for PostgreSQL completely written in TypeScript.

License

Notifications You must be signed in to change notification settings

tohel17/postgresql-client

 
 

Repository files navigation

postgresql-client

NPM Version NPM Downloads Build Status Test Coverage

Professional PostgreSQL client written in TypeScript.

Features

  • Pure JavaScript library completely written in TypeScript
  • Supports both single connection and pooling
  • Named Prepared Statements
  • Extended cursor support with fast double-link cache
  • Extensible data-types and type mapping
  • Extended bind parameters
  • Multidimensional arrays with fast binary encoding/decoding
  • Low memory utilization and boosted performance with Shared Buffers
  • Full binary and text wire protocol support for all data types
  • Supports Clear text, MD5 and SASL password algorithms
  • Can return both array and object rows
  • Asynchronous Promise based api
  • Strictly typed

Installation

$ npm install postgresql-client --save

Documentation

Please read DOCUMENTATION for detailed usage.

import {Connection} from 'postgresql-client';

const connection = new Connection('postgres://localhost');
await connection.connect();
const result = await connection.query(
    'select * from cities where name like $1',
    {params: ['%york%']});
const rows = result.rows;
await connection.close(); // Disconnect
import {Pool} from 'postgresql-client';

const db = new Pool({
    host: 'postgres://localhost',
    pool: {
       min: 1,
       max: 10,
       idleTimeoutMillis: 5000
    }
});

const result = await db.query(
    'select * from cities where name like $1',
    {params: ['%york%'], cursor: true});
const cursor = result.cursor;
let row;
while ((row = cursor.next())) {
  console.log(row);
}

await db.close(); // Disconnect all connections and shutdown pool

Support

You can report bugs and discuss features on the GitHub issues page When you open an issue please provide version of NodeJS and PostgreSQL server.

Node Compatibility

  • node >= 10.x

License

postgresql-client is available under MIT license.

About

Pure JavaScript client for PostgreSQL completely written in TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%