Skip to content

Commit 3730594

Browse files
committed
refactor: remove redundant session functions
1 parent db99dad commit 3730594

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

package/src/operations/session.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,27 @@ import { closeDatabaseQueue, openDatabaseQueue } from '../DatabaseQueue'
1717
export function open(
1818
options: NitroSQLiteConnectionOptions,
1919
): NitroSQLiteConnection {
20-
openDb(options.name, options.location)
20+
try {
21+
HybridNitroSQLite.open(options.name, options.location)
22+
openDatabaseQueue(options.name)
23+
} catch (error) {
24+
throw NitroSQLiteError.fromError(error)
25+
}
2126

2227
return {
23-
close: () => close(options.name),
28+
close: () => {
29+
try {
30+
HybridNitroSQLite.close(options.name)
31+
closeDatabaseQueue(options.name)
32+
} catch (error) {
33+
throw NitroSQLiteError.fromError(error)
34+
}
35+
},
2436
delete: () => HybridNitroSQLite.drop(options.name, options.location),
2537
attach: (dbNameToAttach: string, alias: string, location?: string) =>
2638
HybridNitroSQLite.attach(options.name, dbNameToAttach, alias, location),
2739
detach: (alias: string) => HybridNitroSQLite.detach(options.name, alias),
28-
transaction: (fn: (tx: Transaction) => Promise<void> | void) =>
40+
transaction: <Result = void>(fn: (tx: Transaction) => Promise<Result>) =>
2941
transaction(options.name, fn),
3042
execute: <Row extends QueryResultRow = never>(
3143
query: string,
@@ -45,21 +57,3 @@ export function open(
4557
HybridNitroSQLite.loadFileAsync(options.name, location),
4658
}
4759
}
48-
49-
export function openDb(dbName: string, location?: string) {
50-
try {
51-
HybridNitroSQLite.open(dbName, location)
52-
openDatabaseQueue(dbName)
53-
} catch (error) {
54-
throw NitroSQLiteError.fromError(error)
55-
}
56-
}
57-
58-
export function close(dbName: string) {
59-
try {
60-
HybridNitroSQLite.close(dbName)
61-
closeDatabaseQueue(dbName)
62-
} catch (error) {
63-
throw NitroSQLiteError.fromError(error)
64-
}
65-
}

0 commit comments

Comments
 (0)