Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.7 KB
Raw Blame
use std::sync::Arc;
use tauri::State;

use super::connection::AppState;
pub use dbx_core::history::{HistoryConnectionOption, HistoryEntry, HistorySearchRequest, HistorySearchResult};

#[tauri::command]
pub async fn save_history(state: State<'_, Arc<AppState>>, entry: HistoryEntry) -> Result<(), String> {
    state.storage.save_history_entry(&entry).await
}

#[tauri::command]
pub async fn load_history(
    state: State<'_, Arc<AppState>>,
    limit: usize,
    offset: usize,
    activity_kind: Option<String>,
) -> Result<Vec<HistoryEntry>, String> {
    state.storage.load_history_entries(limit, offset, activity_kind).await
}

#[tauri::command]
pub async fn search_history(
    state: State<'_, Arc<AppState>>,
    request: HistorySearchRequest,
) -> Result<HistorySearchResult, String> {
    state.storage.search_history_entries(request).await
}

#[tauri::command]
pub async fn load_history_connection_options(
    state: State<'_, Arc<AppState>>,
) -> Result<Vec<HistoryConnectionOption>, String> {
    state.storage.load_history_connection_options().await
}

#[tauri::command]
pub async fn clear_history(state: State<'_, Arc<AppState>>) -> Result<(), String> {
    state.storage.clear_history().await
}

#[tauri::command]
pub async fn clear_history_by_source(state: State<'_, Arc<AppState>>, source: String) -> Result<(), String> {
    state.storage.clear_history_by_source(&source).await
}

#[tauri::command]
pub async fn cleanup_mcp_history_retention(state: State<'_, Arc<AppState>>) -> Result<u64, String> {
    state.storage.cleanup_mcp_history_retention().await
}

#[tauri::command]
pub async fn delete_history_entry(state: State<'_, Arc<AppState>>, id: String) -> Result<(), String> {
    state.storage.delete_history_entry(&id).await
}