Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
/ pgc4d Public archive

A full-featured PostgreSQL Client for Deno

License

Notifications You must be signed in to change notification settings

jakajancar/pgc4d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgc4d - PostgreSQL client for Deno

release ci deno doc license

A full-featured PostgreSQL client for Deno including support for:

  • Connectivity using TCP, SSL* and Unix domain sockets*
  • Buffered and streaming responses
  • Various shapes of result sets (keyed rows, indexed rows, column, etc.)
  • Asynchronous notifications (using LISTEN and NOTIFY)
  • Arrays, record types and user-defined types (enums)
  • Concurrent queries (queueing)

Philosophical differences from deno-postgres:

  • Does not aim for API compatibility with Node's node-postgres
  • Uses only binary value encoding in client <> server communication
  • No magic detection of data types (is [1, 2, 3] an int[] or a json value?) - see bugs
  • Strict layering of protocol and logic layers - see the interface

(* currently requires --unstable in Deno)

Usage

import { connectPg } from 'https://deno.land/x/pgc4d/src/mod.ts'

const db = await connectPg('postgres://username:password@hostname/database')
try {
    const result = await db.query('SELECT $1::int + $2::int sum', [10, 20])
    assertEquals(result.rows[0].sum, 30)
} finally {
    db.close()
}

Documentation

API documentation

Manual

Contributing

Happy to accept fixes and improvements.

  1. Please add tests for added functionality and ensure CI passes.
  2. Follow the prevalent coding style (no semicolons, no 80-char line limit, single quotes, etc.)

You can use Docker to bring up PostgreSQL and run the tests:

$ docker-compose run ci

License

Licensed under the MIT license.