From 7919ff032afc8d998041f545a5870e955d0689e6 Mon Sep 17 00:00:00 2001 From: Forato Date: Wed, 25 Jun 2025 18:45:23 -0300 Subject: [PATCH] feat: implement open in lib.rs --- bindings/javascript/src/lib.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bindings/javascript/src/lib.rs b/bindings/javascript/src/lib.rs index 4429b70e4..6837399d0 100644 --- a/bindings/javascript/src/lib.rs +++ b/bindings/javascript/src/lib.rs @@ -4,7 +4,7 @@ use std::cell::{RefCell, RefMut}; use std::num::NonZeroUsize; use std::rc::Rc; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use limbo_core::{LimboError, StepResult}; use napi::iterator::Generator; @@ -35,8 +35,7 @@ pub struct Database { pub readonly: bool, // #[napi(writable = false)] // pub in_transaction: bool, - // #[napi(writable = false)] - // pub open: bool, + pub open: bool, #[napi(writable = false)] pub name: String, _db: Arc, @@ -80,6 +79,7 @@ impl Database { memory, _db: db, conn, + open: true, name: path, io, }) @@ -126,6 +126,11 @@ impl Database { self.readonly } + #[napi] + pub fn open(&self) -> bool { + self.open + } + #[napi] pub fn backup(&self) { todo!() @@ -199,8 +204,9 @@ impl Database { } #[napi] - pub fn close(&self) -> napi::Result<()> { + pub fn close(&mut self) -> napi::Result<()> { self.conn.close().map_err(into_napi_error)?; + self.open = false; Ok(()) } }