bindings/js: Add extension loading

This commit is contained in:
Diego Reis
2025-05-26 12:25:43 -03:00
parent dd029b3d37
commit 7dc69c9c39
3 changed files with 23 additions and 12 deletions

View File

@@ -109,13 +109,18 @@ impl Database {
}
#[napi]
pub fn load_extension(&self) {
todo!()
pub fn load_extension(&self, path: String) -> napi::Result<()> {
let ext_path = limbo_core::resolve_ext_path(path.as_str()).map_err(into_napi_error)?;
self.conn
.load_extension(ext_path)
.map_err(into_napi_error)?;
Ok(())
}
#[napi]
pub fn exec(&self) {
todo!()
pub fn exec(&self, sql: String) -> napi::Result<()> {
self.conn.query(sql).map_err(into_napi_error)?;
Ok(())
}
#[napi]
@@ -133,7 +138,8 @@ impl Database {
let pragma_name = pragma
.split("PRAGMA")
.find(|s| !s.trim().is_empty())
.unwrap();
.unwrap()
.trim();
let mut results = env.create_empty_array()?;