Skip to content

Commit e0c08cc

Browse files
committed
feat: add isExcusive parameter to transaction
1 parent 5ec8a19 commit e0c08cc

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
@@ -22,7 +22,8 @@ export interface PendingTransaction {
2222

2323
export const transaction = (
2424
dbName: string,
25-
fn: (tx: Transaction) => Promise<void> | void
25+
fn: (tx: Transaction) => Promise<void> | void,
26+
isExclusive = false
2627
): Promise<void> => {
2728
if (locks[dbName] == null)
2829
throw Error(`Nitro SQLite Error: No lock found on db: ${dbName}`)
@@ -78,7 +79,10 @@ export const transaction = (
7879

7980
async function run() {
8081
try {
81-
await HybridNitroSQLite.executeAsync(dbName, 'BEGIN TRANSACTION')
82+
await HybridNitroSQLite.executeAsync(
83+
dbName,
84+
isExclusive ? 'BEGIN EXCLUSIVE TRANSACTION' : 'BEGIN TRANSACTION'
85+
)
8286

8387
await fn({
8488
commit,

0 commit comments

Comments
 (0)