class Client
extends QueryClient
Clients allow you to communicate with your PostgreSQL database and execute SQL statements asynchronously
import { Client } from "jsr:@db/postgres"; const client = new Client(); await client.connect(); await client.queryArray`SELECT * FROM CLIENTS`; await client.end();
A client will execute all their queries in a sequential fashion, for concurrency capabilities check out connection pools
import { Client } from "jsr:@db/postgres"; const client_1 = new Client(); await client_1.connect(); // Even if operations are not awaited, they will be executed in the order they were // scheduled client_1.queryArray`DELETE FROM CLIENTS`; const client_2 = new Client(); await client_2.connect(); // `client_2` will execute it's queries in parallel to `client_1` const {rows: result} = await client_2.queryArray`SELECT * FROM CLIENTS`; await client_1.end(); await client_2.end();
Constructors
new Client(config?: ClientOptions | ConnectionString)Create a new client