mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-29 16:18:55 +00:00
feat(sql): persist SQL library in app database
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user