Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/oak_nest/modules/postgres/mod.ts>Client

Refer to nestjs to realize some common functions for Deno
Go to Latest
class Client
extends QueryClient
Re-export
import { Client } from "https://deno.land/x/oak_nest@v1.15.1/modules/postgres/mod.ts";

Clients allow you to communicate with your PostgreSQL database and execute SQL statements asynchronously

import { Client } from "./client.ts";

const client = new Client();
await client.connect();
await client.queryArray`UPDATE MY_TABLE SET MY_FIELD = 0`;
await client.end();

A client will execute all their queries in a sequential fashion, for concurrency capabilities check out connection pools

import { Client } from "./client.ts";

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`UPDATE MY_TABLE SET MY_FIELD = 0`;
client_1.queryArray`DELETE FROM MY_TABLE`;

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 MY_TABLE`;

await client_1.end();
await client_2.end();