feat(mongodb): support generic runCommand execution
This commit is contained in:
1 parent
2d00620fac
commit
9b24d962bb
27 files changed
+580
-18
No files matched your search
@@ -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>>,
|
||||
|
||||
@@ -2001,6 +2001,7 @@ pub fn run() {
|
||||
commands::mongo_cmd::mongo_distinct,
|
||||
commands::mongo_cmd::mongo_create_index,
|
||||
commands::mongo_cmd::mongo_create_user,
|
||||
commands::mongo_cmd::mongo_run_command,
|
||||
commands::mongo_cmd::mongo_drop_indexes,
|
||||
commands::document_cmd::document_insert_document,
|
||||
commands::mongo_cmd::mongo_insert_document,
|
||||
|
||||
Reference in new issue
Block a user