bindings/javascript: Fix Database.close()

We need to drop reference to `turso_core::Database` for this to work.
This commit is contained in:
Pekka Enberg
2025-07-28 12:20:02 +03:00
parent 551df4ce0d
commit edbbeefed5

View File

@@ -65,7 +65,7 @@ pub struct Database {
pub open: bool,
#[napi(writable = false)]
pub name: String,
_db: Arc<turso_core::Database>,
db: Option<Arc<turso_core::Database>>,
conn: Arc<turso_core::Connection>,
_io: Arc<dyn turso_core::IO>,
}
@@ -108,7 +108,7 @@ impl Database {
Ok(Self {
readonly: opts.readonly(),
memory,
_db: db,
db: Some(db),
conn,
open: true,
name: path,
@@ -237,6 +237,7 @@ impl Database {
pub fn close(&mut self) -> napi::Result<()> {
if self.open {
self.conn.close().map_err(into_napi_error)?;
self.db.take();
self.open = false;
}
Ok(())