You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
914 B
TypeScript
31 lines
914 B
TypeScript
// import { Pool } from "pg";
|
|
import { neon } from "@neondatabase/serverless";
|
|
import { Kysely /*PostgresDialect*/ } from "kysely";
|
|
import { NeonDialect } from "kysely-neon";
|
|
import type Database from "./generated/Database";
|
|
|
|
// export const pool = new Pool({
|
|
// connectionString: env.POSTGRES_CONNECTION_STRING as string,
|
|
// // channelBinding: require ?
|
|
// });
|
|
|
|
// const dialect = new PostgresDialect({
|
|
// pool,
|
|
// });
|
|
|
|
export function getDbClient(POSTGRES_CONNECTION_STRING: string) {
|
|
const dialect = new NeonDialect({
|
|
neon: neon(POSTGRES_CONNECTION_STRING as string),
|
|
});
|
|
|
|
// Database interface is passed to Kysely's constructor, and from now on, Kysely
|
|
// knows your database structure.
|
|
// Dialect is passed to Kysely's constructor, and from now on, Kysely knows how
|
|
// to communicate with your database.
|
|
const dbClient = new Kysely<Database>({
|
|
dialect,
|
|
});
|
|
|
|
return dbClient;
|
|
}
|