mirror of
https://github.com/better-auth/better-auth.git
synced 2026-07-30 06:04:15 -05:00
fix(create-adapter): disable transaction by default (#4750)
This commit is contained in:
@@ -9,6 +9,7 @@ import type {
|
||||
} from "../../types";
|
||||
import { generateId as defaultGenerateId, logger } from "../../utils";
|
||||
import type {
|
||||
AdapterFactoryConfig,
|
||||
AdapterFactoryOptions,
|
||||
AdapterTestDebugLogs,
|
||||
CleanedWhere,
|
||||
@@ -69,7 +70,8 @@ export const createAdapterFactory =
|
||||
supportsJSON: cfg.supportsJSON ?? false,
|
||||
adapterName: cfg.adapterName ?? cfg.adapterId,
|
||||
supportsNumericIds: cfg.supportsNumericIds ?? true,
|
||||
};
|
||||
transaction: cfg.transaction ?? false,
|
||||
} satisfies AdapterFactoryConfig;
|
||||
|
||||
if (
|
||||
options.advanced?.database?.useNumberId === true &&
|
||||
|
||||
@@ -99,7 +99,8 @@ export interface AdapterFactoryConfig {
|
||||
* Execute multiple operations in a transaction.
|
||||
*
|
||||
* If the database doesn't support transactions, set this to `false` and operations will be executed sequentially.
|
||||
*
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
transaction?:
|
||||
| false
|
||||
|
||||
@@ -361,7 +361,7 @@ export const drizzleAdapter = (db: DB, config: DrizzleAdapterConfig) => {
|
||||
usePlural: config.usePlural ?? false,
|
||||
debugLogs: config.debugLogs ?? false,
|
||||
transaction:
|
||||
(config.transaction ?? true)
|
||||
(config.transaction ?? false)
|
||||
? (cb) =>
|
||||
db.transaction((tx: DB) => {
|
||||
const adapter = createAdapterFactory({
|
||||
|
||||
@@ -372,7 +372,7 @@ export const kyselyAdapter = (
|
||||
: true,
|
||||
supportsJSON: false,
|
||||
transaction:
|
||||
(config?.transaction ?? true)
|
||||
(config?.transaction ?? false)
|
||||
? (cb) =>
|
||||
db.transaction().execute((trx) => {
|
||||
const adapter = createAdapterFactory({
|
||||
|
||||
@@ -282,7 +282,7 @@ export const mongodbAdapter = (db: Db, config?: MongoDBAdapterConfig) => {
|
||||
},
|
||||
supportsNumericIds: false,
|
||||
transaction:
|
||||
config?.client && (config?.transaction ?? true)
|
||||
config?.client && (config?.transaction ?? false)
|
||||
? async (cb) => {
|
||||
if (!config.client) {
|
||||
return cb(lazyAdapter!(lazyOptions!));
|
||||
|
||||
@@ -241,7 +241,7 @@ export const prismaAdapter = (prisma: PrismaClient, config: PrismaConfig) => {
|
||||
usePlural: config.usePlural ?? false,
|
||||
debugLogs: config.debugLogs ?? false,
|
||||
transaction:
|
||||
(config.transaction ?? true)
|
||||
(config.transaction ?? false)
|
||||
? (cb) =>
|
||||
(prisma as PrismaClientInternal).$transaction((tx) => {
|
||||
const adapter = createAdapterFactory({
|
||||
|
||||
Reference in New Issue
Block a user