import {
type Sql,
} from "https://deno.land/x/windmill@v1.88.1/mod.ts";
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;
};
export async function main(db: Postgresql, query: Sql = "SELECT * FROM demo;") {
if (!query) {
throw Error("Query must not be empty.");
}
const { rows } = await pgClient(db).queryObject(query);
return rows;
}
export function pgClient(db: any) {
let db2 = {
...db,
hostname: db.host,
database: db.dbname,
tls: {
enabled: false,
},
}
return new Client(db2)
}
Submitted by rubenfiszel 286 days ago
import {
pgClient,
type Sql,
} from "https://deno.land/x/windmill@v1.88.1/mod.ts";
type Postgresql = {
host: string;
port: number;
user: string;
dbname: string;
sslmode: string;
password: string;
};
export async function main(db: Postgresql, query: Sql = "SELECT * FROM demo;") {
if (!query) {
throw Error("Query must not be empty.");
}
const { rows } = await pgClient(db).queryObject(query);
return rows;
}
Submitted by admin 497 days ago
import { pgClient, type Sql } from "https://deno.land/x/windmill@v1.88.1/mod.ts";
type Postgresql = {
host: string;
port: number;
user: string;
dbname: string;
sslmode: string;
password: string;
};
export async function main(
db: Postgresql,
query: Sql = "SELECT * FROM demo;",
) {
if(!query) {
throw Error('Query must not be empty.')
}
const { rows } = await pgClient(db).queryObject(query);
return rows;
}
Submitted by admin 500 days ago
import { pgClient, type Resource, type Sql } from "https://deno.land/x/windmill@v1.88.1/mod.ts";
export async function main(
db: Resource<"postgresql">,
query: Sql = "SELECT * FROM demo;",
) {
if(!query) {
throw Error('Query must not be empty.')
}
const { rows } = await pgClient(db).queryObject(query);
return rows;
}
Submitted by adam186 612 days ago
import { pgClient, type Resource, type Sql } from "https://deno.land/x/windmill@v1.88.1/mod.ts";
export async function main(
db: Resource<"postgresql">,
query: Sql = "SELECT * FROM demo",
) {
return await pgClient(db).queryObject(query);
}
Submitted by adam186 612 days ago
import { pgQuery } from "https://deno.land/x/windmill@v1.85.0/pg.ts";
import type { Resource, Sql } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
export async function main(
db: Resource<"postgresql">,
query: Sql = "select * from demo",
) {
return await pgQuery(db, query);
}
Submitted by adam186 628 days ago
import { pgQuery } from "https://deno.land/x/windmill@v1.31.0/pg.ts";
import type { Resource, Sql } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
export async function main(
db: Resource<"postgresql">,
query: Sql = "select * from demo",
) {
return await pgQuery(db, query);
}
Submitted by adam186 663 days ago
import { pgQuery } from "https://deno.land/x/windmill@v1.31.0/pg.ts";
import type { Resource, Sql } from "https://deno.land/x/windmill@v1.31.0/mod.ts";
export async function main(
db: Resource<"postgresql">,
query: Sql = "select * from demo",
) {
return await pgQuery(db, query);
}
Submitted by admin 858 days ago
import { pgQuery } from "https://deno.land/x/windmill@v1.31.0/pg.ts";
import type { Resource } from "https://deno.land/x/windmill@v1.31.0/mod.ts";
export async function main(
db: Resource<"postgresql">,
query: string = "select * from demo",
) {
return await pgQuery(db, query);
}
Submitted by admin 858 days ago
import * as wmill from "https://deno.land/x/windmill@v1.27.2/mod.ts";
import { Client } from "https://deno.land/x/postgres@v0.16.1/mod.ts";
export async function main(db: wmill.Resource<"postgresql">, query: wmill.Sql) {
db.database = db.dbname;
db.hostname = db.host;
const client = new Client(db);
const returned_query = await client.queryObject(query);
return returned_query;
}
Submitted by rossmccrann 871 days ago