import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
import * as wmill from "https://deno.land/x/windmill@v1.100.2/mod.ts";
//PG parameterized statement. No SQL injection is possible.
export async function main(
dbConfig: wmill.Resource<"postgresql">,
tlsSettings: wmill.Resource<"postgres-tls">,
sql: string,
) {
// small hack since we want to store the caCertificate as a secret in winmill.
dbConfig.tls = tlsSettings;
dbConfig.tls.caCertificates = [dbConfig.tls.caCertificate];
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