InvalidStateError for IndexedDB Example in Rust WebAssembly Environment
dagarcia7 opened this issue · comments
Hello!
I'm trying to get a simple IndexedDB example working in a Rust WASM environment, but am running into an issue. Below is the function I'm trying to expose to the WASM
use wasm_bindgen::prelude::*;
use gluesql::{prelude::Glue, idb_storage::IdbStorage};
#[wasm_bindgen]
pub async fn create_indexed_db() {
let storage_name = Some(String::from("testdb"));
let idb_storage_result = IdbStorage::new(storage_name).await.expect("Something went wrong!");
let mut glue = Glue::new(idb_storage_result);
let queries = "
CREATE TABLE greet (name TEXT);
";
match glue.execute(queries).await {
Ok(_) => web_sys::console::log_1(&"Queries executed successfully".into()),
Err(e) => {
let error_message = format!("Execution failed: {:?}", e);
web_sys::console::log_1(&error_message.into());
},
}
}
and this is the error I'm getting when calling the function in a test html example
Execution failed: StorageMsg("failed to commit transaction: InvalidStateError: Failed to execute 'commit' on 'IDBTransaction': The transaction is not active.")
When I check the Application -> IndexedDB tabs in Google Chrome, I do see the testdb
get created, but the query to create the table isn't executed. I also tried the query CREATE TABLE greet (name TEXT) ENGINE = indexedDB;
per the documentation here, but that didn't work either.
I'm not sure if this is an error with GlueSQL, if there is something I have done wrong in the code, or if this type of thing is not supported in general. I tried my best to follow the examples in the documentation and in this repository to piece together the small example I provided. I figured this is the best way to reach out for support, but happy to drop this question/issue somewhere else if need be!
Thanks!