import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
import { Resource } from "https://deno.land/x/windmill@v1.100.2/mod.ts";
export async function main(
dbConfig: Resource<"postgresql">,
cacertificate: Resource<"postgresql-cacertificate">,
sql: string = "SELECT 1 as id",
) {
dbConfig.tls = {
enabled: true,
enforce: true,
caCertificates: [cacertificate.certificate]
}
console.log(dbConfig.tls)
const client = new Client(dbConfig);
await client.connect();
const res = await client.queryObject(
sql,
);
await client.end();
return res.rows;
}
Submitted by sindre svendby964 587 days ago