mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-05 00:03:08 +00:00
add pgQuery to deno-client
This commit is contained in:
@@ -132,3 +132,4 @@ export async function databaseUrlFromResource(path: string): Promise<string> {
|
||||
const resource = await getResource(path)
|
||||
return `postgresql://${resource.user}:${resource.password}@${resource.host}:${resource.port}/${resource.dbname}?sslmode=${resource.sslmode}`
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Client } from "https://deno.land/x/postgres@v0.16.1/mod.ts"
|
||||
import { type Resource, type Sql } from "./mod.ts"
|
||||
|
||||
export async function pgQuery(
|
||||
db: Resource<"postgresql">,
|
||||
query: Sql
|
||||
) {
|
||||
db.database = db.dbname
|
||||
db.hostname = db.host
|
||||
|
||||
const returned_query = await new Client(db).queryObject(query)
|
||||
|
||||
return returned_query.rows
|
||||
}
|
||||
Reference in New Issue
Block a user