postgresql-client
Professional PostgreSQL client written in TypeScript.
import {Connection} from 'postgresql-client';
const connection = new Connection('postgres://localhost');
const result = await connection.query(
'select * from cities where name like $1',
{values: ['%york%']});
const rows = result.rows;
await connection.close();
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',
{values: ['%york%'], cursor: true});
const cursor = result.cursor;
let row;
while ((row = cursor.next())) {
console.log(row);
}
await db.close();
Features
- Pure JavaScript library completely written in TypeScript
- Supports both single connection and pooling
- Supports named Prepared Statements
- Extended cursor support with fast double-link cache
- Extensible data-types and type mapping
- Extended bind parameter support
- Fast array support with binary encoding/decoding
- Low memory utilization and boosted performance with Shared Buffers
- Full binary wire protocol support for all data types
- Already supports text wire protocol
- Built-in ScriptExecutor which allows executing multiple scripts at once
- Asynchronous Promise based api
- Strictly typed
- Can return both array and object rows
Roadmap
- Support multiple active cursors
Installation
$ npm install postgresql-client --save
Documentation
Documentation for detailed usage is here
Support
You can report bugs and discuss features on the GitHub issues page
When you open an issue please provide version of NodeJS, PostgreSQL server an
Node Compatibility
License
postgresql-client is available under MIT license.