Gaspero
Deno usage
Hey! I was also searching for any examples of postgres-js usage in deno. Didn't find any but managed to set it up using https://github.com/igalklebanov/kysely-postgres-js adapter
// import_map.json
{
"imports": {
"kysely": "https://cdn.jsdelivr.net/npm/[email protected]/dist/esm/index.js",
"postgres": "https://deno.land/x/[email protected]/mod.js",
"kysely-postgres-js": "https://cdn.jsdelivr.net/npm/kysely-postgres-js/dist/esm/index.js"
}
}
// index.ts
import { PostgresJSDialect } from "kysely-postgres-js"
import {
GeneratedAlways,
Kysely,
} from 'kysely'
import postgres from 'postgres'
// ...
const db = new Kysely<Database>({
dialect: new PostgresJSDialect({
postgres: postgres(DATABASE_URL),
}),
})
4 replies
Running database agnostic queries (MySQL)
Ah. I'm sorry, I thought the question was about create/drop table.
If database connection has sufficient permissions may be you could solve this by running raw sql? https://kysely-org.github.io/kysely/interfaces/Sql.html
E.g.
8 replies
Running database agnostic queries (MySQL)
Take a look at migration section of docs https://kysely.dev/docs/migrations
Seems like you could use such approach as a workaround to write database structure agnostic queries .
async function functionName(db: Kysely<any>): Promise<void> {
// database agnostic query
}
But you would still need to initialize driver for each specific database connection.8 replies