adapt WASM to new API

main
Ziyang Hu 2 years ago
parent d278768f82
commit 01f508188d

@ -18,7 +18,7 @@ exclude = [
[features] [features]
#! # Features #! # Features
default = ["compact", "storage-rocksdb"] default = ["compact"]
## Enables the `minimal`, `requests` and `graph-algo` features ## Enables the `minimal`, `requests` and `graph-algo` features
compact = ["minimal", "requests", "graph-algo", "rayon"] compact = ["minimal", "requests", "graph-algo", "rayon"]
## Enables the `minimal`, `requests` and `graph-algo` features in single threaded mode ## Enables the `minimal`, `requests` and `graph-algo` features in single threaded mode

@ -25,17 +25,23 @@ extern "C" {
#[wasm_bindgen] #[wasm_bindgen]
pub struct CozoDb { pub struct CozoDb {
db: Db<MemStorage>, db: DbInstance,
} }
#[wasm_bindgen] #[wasm_bindgen]
impl CozoDb { impl CozoDb {
pub fn new() -> Self { pub fn new() -> Self {
utils::set_panic_hook(); utils::set_panic_hook();
let db = new_cozo_mem().unwrap(); let db = DbInstance::new("mem", "", Default::default()).unwrap();
Self { db } Self { db }
} }
pub fn run(&self, script: &str, params: &str) -> String { pub fn run(&self, script: &str, params: &str) -> String {
self.db.run_script_str(script, params) self.db.run_script_str(script, params)
} }
pub fn export_relations(&self, rels: &str) -> String {
self.db.export_relations_str(rels)
}
pub fn import_relation(&self, data: &str) -> String {
self.db.import_relation_str(data)
}
} }

Loading…
Cancel
Save