feat(mongodb): support generic runCommand execution

This commit is contained in:
Guoyu Su authored and GitHub committed 2026-08-12 21:05:13 +08:00
1 parent 2d00620fac
commit 9b24d962bb
27 files changed
+580 -18

No files matched your search

+28
View File
@@ -383,6 +383,34 @@ pub async fn mongo_create_user(
Ok(serde_json::json!({ "affected_rows": affected_rows }))
}
#[tauri::command]
pub async fn mongo_run_command(
state: State<'_, Arc<AppState>>,
connection_id: String,
database: String,
command_json: String,
execution_id: Option<String>,
mcp_request: Option<bool>,
) -> Result<MongoDocumentResult, String> {
if mcp_request == Some(true) {
crate::commands::mcp_bridge::ensure_mcp_dangerous_write_allowed_by_id(
state.inner(),
&connection_id,
&database,
"Run MongoDB command",
)
.await?;
}
ensure_connection_writable(&state, &connection_id, "Run MongoDB command").await?;
let app = state.inner().clone();
run_cancellable(
&app,
execution_id,
dbx_core::mongo_ops::mongo_run_command_core(&app, &connection_id, &database, &command_json),
)
.await
}
#[tauri::command]
pub async fn mongo_drop_indexes(
state: State<'_, Arc<AppState>>,