import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
type Postgresql = {
host: string;
port: number;
user: string;
dbname: string;
sslmode: string;
password: string;
};
type Cacertificate = {
certificate: string;
};
export async function main(
dbConfig: Postgresql,
cacertificate: Cacertificate,
sql: string = "SELECT 1 as id",
) {
dbConfig.tls = {
enabled: true,
enforce: true,
caCertificates: [cacertificate.certificate],
};
const client = new Client(dbConfig);
await client.connect();
const res = await client.queryObject(sql);
await client.end();
return res.rows;
}
Submitted by admin 497 days ago
import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
type Postgresql = {
host: string;
port: number;
user: string;
dbname: string;
sslmode: string;
password: string;
};
type Cacertificate = {
certificate: string;
};
export async function main(
dbConfig: Postgresql,
cacertificate: Cacertificate,
sql: string = "SELECT 1 as id",
) {
dbConfig.tls = {
enabled: true,
enforce: true,
caCertificates: [cacertificate.certificate]
}
const client = new Client(dbConfig);
await client.connect();
const res = await client.queryObject(
sql,
);
await client.end();
return res.rows;
}
Submitted by admin 500 days ago
import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
import type { Resource } from "https://deno.land/x/windmill@v1.101.1/mod.ts"
export async function main(
dbConfig: Resource<"postgresql">,
cacertificate: Resource<"cacertificate">,
sql: string = "SELECT 1 as id",
) {
dbConfig.tls = {
enabled: true,
enforce: true,
caCertificates: [cacertificate.certificate]
}
const client = new Client(dbConfig);
await client.connect();
const res = await client.queryObject(
sql,
);
await client.end();
return res.rows;
}
Submitted by sindre svendby964 580 days ago
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<"cacertificate">,
sql: string = "SELECT 1 as id",
) {
dbConfig.tls = {
enabled: true,
enforce: true,
caCertificates: [cacertificate.certificate]
}
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