mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 04:19:32 +00:00
feat: database transaction support (#4414)
Co-authored-by: Joel Solano <solano.joel@gmx.de>
This commit is contained in:
@@ -20,7 +20,7 @@ const client = new MongoClient("mongodb://localhost:27017/database");
|
||||
const db = client.db();
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: mongodbAdapter(db),
|
||||
database: mongodbAdapter(db, { client }),
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -452,6 +452,16 @@ const adapter = myAdapter({
|
||||
});
|
||||
```
|
||||
|
||||
### `transaction`
|
||||
|
||||
Whether the adapter supports transactions. If `false`, operations run sequentially; otherwise provide a function that executes a callback with a `TransactionAdapter`.
|
||||
|
||||
<Callout type="warn">
|
||||
If your database does not support transactions, the error handling and rollback
|
||||
will not be as robust. We recommend using a database that supports transactions
|
||||
for better data integrity.
|
||||
</Callout>
|
||||
|
||||
### `debugLogs`
|
||||
|
||||
Used to enable debug logs for the adapter. You can pass in a boolean, or an object with the following keys: `create`, `update`, `updateMany`, `findOne`, `findMany`, `delete`, `deleteMany`, `count`.
|
||||
|
||||
Reference in New Issue
Block a user