Skip to content

Commit 7f6e1ed

Browse files
committed
feat: add isExcusive parameter to transaction
1 parent d1d6f99 commit 7f6e1ed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

package/src/operations/transaction.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import NitroSQLiteError from '../NitroSQLiteError'
1111

1212
export const transaction = (
1313
dbName: string,
14-
fn: (tx: Transaction) => Promise<void> | void
14+
fn: (tx: Transaction) => Promise<void> | void,
15+
isExclusive = false
1516
): Promise<void> => {
1617
throwIfDatabaseIsNotOpen(dbName)
1718

@@ -67,7 +68,10 @@ export const transaction = (
6768
try {
6869
return queueOperationAsync(dbName, async () => {
6970
try {
70-
await HybridNitroSQLite.executeAsync(dbName, 'BEGIN TRANSACTION')
71+
await HybridNitroSQLite.executeAsync(
72+
dbName,
73+
isExclusive ? 'BEGIN EXCLUSIVE TRANSACTION' : 'BEGIN TRANSACTION'
74+
)
7175

7276
await fn({
7377
commit,

0 commit comments

Comments
 (0)