PostgreSQL driver for Deno.
It's still work in progress, but you can take it for a test drive!
deno-postgres
is being developed based on excellent work of
node-postgres and
pq.
// deno run --allow-net --allow-read --unstable mod.ts
import { Client } from "https://deno.land/x/postgres/mod.ts";
const client = new Client({
user: "user",
database: "test",
hostname: "localhost",
port: 5432,
});
await client.connect();
{
const result = await client.queryArray("SELECT ID, NAME FROM PEOPLE");
console.log(result.rows); // [[1, 'Carlos'], [2, 'John'], ...]
}
{
const result = await client.queryObject("SELECT ID, NAME FROM PEOPLE");
console.log(result.rows); // [{id: 1, name: 'Carlos'}, {id: 2, name: 'Johnru'}, ...]
}
await client.end();
Due to the use of the Deno.startTls
API, the library require to pass the
--unstable
for it's usage. This is a situation that will be solved when that
API is stabilized.
Docs are available at https://deno-postgres.com/
When contributing to repository make sure to:
- All features and fixes must have an open issue in order to be discussed
- All public interfaces must be typed and have a corresponding JS block explaining their usage
- All code must pass the format and lint checks enforced by
deno fmt
anddeno lint
respectively
There are substantial parts of this library based on other libraries. They have preserved their individual licenses and copyrights.
Eveything is licensed under the MIT License.
All additional work is copyright 2018 - 2021 — Bartłomiej Iwańczuk and Steven Guerrero — All rights reserved.