feat(sql): persist SQL library in app database

This commit is contained in:
t8y2
2026-05-10 00:41:17 +08:00
parent cac383e6bf
commit b013a2ac29
17 changed files with 462 additions and 88 deletions
+1
View File
@@ -8,6 +8,7 @@ pub mod mongo_cmd;
pub mod query;
pub mod query_cancel;
pub mod redis_cmd;
pub mod saved_sql;
pub mod schema;
pub mod schema_cache;
pub mod sql_file;
+35
View File
@@ -0,0 +1,35 @@
use std::sync::Arc;
use tauri::State;
use dbx_core::connection::AppState;
use dbx_core::saved_sql::{SavedSqlFile, SavedSqlFolder, SavedSqlLibrary};
#[tauri::command]
pub async fn load_saved_sql_library(state: State<'_, Arc<AppState>>) -> Result<SavedSqlLibrary, String> {
state.storage.load_saved_sql_library().await
}
#[tauri::command]
pub async fn save_saved_sql_folder(
state: State<'_, Arc<AppState>>,
folder: SavedSqlFolder,
) -> Result<SavedSqlFolder, String> {
state.storage.save_saved_sql_folder(&folder).await?;
Ok(folder)
}
#[tauri::command]
pub async fn delete_saved_sql_folder(state: State<'_, Arc<AppState>>, id: String) -> Result<(), String> {
state.storage.delete_saved_sql_folder(&id).await
}
#[tauri::command]
pub async fn save_saved_sql_file(state: State<'_, Arc<AppState>>, file: SavedSqlFile) -> Result<SavedSqlFile, String> {
state.storage.save_saved_sql_file(&file).await?;
Ok(file)
}
#[tauri::command]
pub async fn delete_saved_sql_file(state: State<'_, Arc<AppState>>, id: String) -> Result<(), String> {
state.storage.delete_saved_sql_file(&id).await
}
+5
View File
@@ -112,6 +112,11 @@ pub fn run() {
commands::redis_cmd::redis_set_ttl,
commands::redis_cmd::redis_delete_keys,
commands::redis_cmd::redis_load_more,
commands::saved_sql::load_saved_sql_library,
commands::saved_sql::save_saved_sql_folder,
commands::saved_sql::delete_saved_sql_folder,
commands::saved_sql::save_saved_sql_file,
commands::saved_sql::delete_saved_sql_file,
commands::mongo_cmd::mongo_list_databases,
commands::mongo_cmd::mongo_list_collections,
commands::mongo_cmd::mongo_find_documents,