import e from"node:path";import{sql as s}from"drizzle-orm";import{drizzle as o}from"drizzle-orm/libsql";import{migrate as c}from"drizzle-orm/libsql/migrator";import{TransactionsManager as l}from"./transactions-manager.js";class r{dbClient;#t;constructor(t,i){this.dbClient=o(i(t)),this.#t=new l(this.dbClient)}get transactionsManager(){return this.#t}get client(){return this.#t.tx??this.dbClient}static async init(t,i){const{createClient:a}=await import("@libsql/client"),n=new r(t,a);return i?.runWithPragmaWalWriteOptimization&&await n.dbClient.run(s.raw("PRAGMA journal_mode = WAL;")),n}async migrate(t,i=""){await c(this.dbClient,{migrationsFolder:e.join(t,"migrations",i)})}async close(){this.dbClient.$client.close()}async sync(){return this.dbClient.$client.sync()}}export{r as DatabaseClient};
