/opt/canhelp/node_modules/better-auth/dist/db
Edit: /opt/canhelp/node_modules/better-auth/dist/db/adapter-base.mjs (994B)
import { getAuthTables } from "@better-auth/core/db";
import { logger } from "@better-auth/core/env";
//#region src/db/adapter-base.ts
async function getBaseAdapter(options, handleDirectDatabase) {
let adapter;
if (!options.database) {
const tables = getAuthTables(options);
const memoryDB = Object.keys(tables).reduce((acc, key) => {
acc[key] = [];
return acc;
}, {});
const { memoryAdapter } = await import("@better-auth/memory-adapter");
adapter = memoryAdapter(memoryDB)(options);
} else if (typeof options.database === "function") adapter = options.database(options);
else adapter = await handleDirectDatabase(options);
if (!adapter.transaction) {
logger.warn("Adapter does not correctly implement transaction function, patching it automatically. Please update your adapter implementation.");
adapter.transaction = async (cb) => {
return cb(adapter);
};
}
return adapter;
}
//#endregion
export { getBaseAdapter };
//# sourceMappingURL=adapter-base.mjs.map