Hello,
I'm struggling with embedding SurrealDB with a persistent engine in a Tauri application (specifically Tauri 2 - beta). Everything works correctly when I use the in-memory engine. However, when I try the same thing, with a simple switch to an engine like RocksDB, SpeeDB, or SurrealKV, everything works properly in the dev environment, but after building the project, it stops working. The application builds without errors, but the functions that in dev created and read records in SurrealDB now do nothing. I'm new to Tauri and Rust, but after several days spent on Google, it doesn't seem like I'm doing anything wrong, although I probably am.
Here's what my lib.rs file looks like, where I initiate SurrealDB:
async fn init_db() -> Result<(), Box<dyn std::error::Error>> {
let db = DB.connect::<SurrealKV>("db/surreal.db").await.expect("Unable to construct Database");
let _ = DB.use_ns("surreal").use_db("local").await;
Ok(db)
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.setup(|app| {
let _main_window = app.get_webview_window("main").unwrap();
tauri::async_runtime::spawn(async {
init_db().await.expect("Something wrong with initiation of DB");
});
Ok(())
})
.invoke_handler(tauri::generate_handler![
ipc::create_user,
ipc::get_user
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Could someone help me with this?