mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-04 17:56:38 +00:00
support postgresql as database option
This commit is contained in:
17
server/db/pg/driver.ts
Normal file
17
server/db/pg/driver.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { drizzle as DrizzlePostgres } from "drizzle-orm/node-postgres";
|
||||
import { readConfigFile } from "@server/lib/readConfigFile";
|
||||
|
||||
function createDb() {
|
||||
const config = readConfigFile();
|
||||
|
||||
const connectionString = config.postgres?.connection_string;
|
||||
|
||||
if (!connectionString) {
|
||||
throw new Error("Postgres connection string is not defined in the configuration file.");
|
||||
}
|
||||
|
||||
return DrizzlePostgres(connectionString);
|
||||
}
|
||||
|
||||
export const db = createDb();
|
||||
export default db;
|
||||
Reference in New Issue
Block a user