bind/js: Close Database connection when it is garbage collected

This commit is contained in:
Diego Reis 2025-05-08 08:36:27 -03:00
parent 787de5e2b3
commit f0a08612b0

View file

@ -34,6 +34,14 @@ pub struct Database {
conn: Rc<limbo_core::Connection>,
}
impl ObjectFinalize for Database {
// TODO: check if something more is required
fn finalize(self, _env: Env) -> napi::Result<()> {
self.conn.close().map_err(into_napi_error)?;
Ok(())
}
}
#[napi]
impl Database {
#[napi(constructor)]