@@ -40,7 +40,7 @@ export async function initSQLiteCore(
40
40
const sqlite = Factory ( sqliteModule )
41
41
const vfs = await vfsFn ( path , sqliteModule , vfsOptions )
42
42
sqlite . vfs_register ( vfs as unknown as SQLiteVFS , true )
43
- beforeOpen ?.( vfs , path )
43
+ await beforeOpen ?.( vfs , path )
44
44
const pointer = await sqlite . open_v2 (
45
45
path ,
46
46
readonly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE ,
@@ -57,14 +57,15 @@ export async function initSQLiteCore(
57
57
}
58
58
59
59
export async function close ( core : SQLiteDBCore ) : Promise < void > {
60
- await core . sqlite . close ( core . db )
60
+ await core . sqlite . close ( core . pointer )
61
+ await core . vfs . close ( )
61
62
}
62
63
export function changes ( core : SQLiteDBCore ) : number | bigint {
63
- return core . sqliteModule . _sqlite3_changes ( core . db )
64
+ return core . sqliteModule . _sqlite3_changes ( core . pointer )
64
65
}
65
66
66
67
export function lastInsertRowId ( core : SQLiteDBCore ) : number | bigint {
67
- return core . sqliteModule . _sqlite3_last_insert_rowid ( core . db )
68
+ return core . sqliteModule . _sqlite3_last_insert_rowid ( core . pointer )
68
69
}
69
70
70
71
export async function stream (
@@ -73,8 +74,8 @@ export async function stream(
73
74
sql : string ,
74
75
parameters ?: SQLiteCompatibleType [ ] ,
75
76
) : Promise < void > {
76
- const { sqlite, db } = core
77
- for await ( const stmt of sqlite . statements ( db , sql ) ) {
77
+ const { sqlite, pointer } = core
78
+ for await ( const stmt of sqlite . statements ( pointer , sql ) ) {
78
79
if ( parameters ?. length ) {
79
80
sqlite . bind_collection ( stmt , parameters )
80
81
}
0 commit comments