fix(mongodb): support createUser shell commands

Closes #5639
This commit is contained in:
t8y2 committed 2026-08-09 15:51:04 +08:00
1 parent e7f496bf0b
commit 9e3013adf9
25 files changed
+481 -12

No files matched your search

+30
View File
@@ -334,6 +334,36 @@ pub async fn mongo_create_index(
Ok(serde_json::json!({ "name": name }))
}
#[tauri::command]
pub async fn mongo_create_user(
state: State<'_, Arc<AppState>>,
connection_id: String,
database: String,
user_json: String,
write_concern_json: Option<String>,
mcp_request: Option<bool>,
) -> Result<serde_json::Value, String> {
if mcp_request == Some(true) {
crate::commands::mcp_bridge::ensure_mcp_dangerous_write_allowed_by_id(
state.inner(),
&connection_id,
&database,
"Create user",
)
.await?;
}
ensure_connection_writable(&state, &connection_id, "Create user").await?;
let affected_rows = dbx_core::mongo_ops::mongo_create_user_core(
&state,
&connection_id,
&database,
&user_json,
write_concern_json.as_deref(),
)
.await?;
Ok(serde_json::json!({ "affected_rows": affected_rows }))
}
#[tauri::command]
pub async fn mongo_drop_indexes(
state: State<'_, Arc<AppState>>,