more tomfoolery again
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
import "dotenv/config";
|
||||
import type { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
|
||||
import type { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite";
|
||||
// import type { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
|
||||
// import type { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite";
|
||||
|
||||
let _db: BunSQLiteDatabase | BetterSQLite3Database;
|
||||
let _db: any;
|
||||
|
||||
if (!process.env.DB_FILE_NAME) {
|
||||
throw new Error("DB_FILE_NAME is not set");
|
||||
}
|
||||
|
||||
if (process.versions.bun) {
|
||||
console.info("Using Bun SQLite");
|
||||
const { drizzle } = await import("drizzle-orm/bun-sqlite");
|
||||
_db = drizzle(process.env.DB_FILE_NAME);
|
||||
} else {
|
||||
console.info("Using Better SQLite3");
|
||||
const { drizzle } = await import("drizzle-orm/better-sqlite3");
|
||||
_db = drizzle(process.env.DB_FILE_NAME);
|
||||
}
|
||||
console.info("Using DB_FILE_NAME: ", process.env.DB_FILE_NAME);
|
||||
|
||||
// if (process.versions.bun) {
|
||||
// console.info("Using Bun SQLite");
|
||||
// const { drizzle } = await import("drizzle-orm/bun-sqlite");
|
||||
// _db = drizzle(process.env.DB_FILE_NAME);
|
||||
// } else {
|
||||
console.info("Using Better SQLite3");
|
||||
const { drizzle } = await import("drizzle-orm/better-sqlite3");
|
||||
_db = drizzle(process.env.DB_FILE_NAME);
|
||||
// }
|
||||
|
||||
export const db = _db;
|
||||
|
||||
Reference in New Issue
Block a user