feat(mongo): add dropIndex and dropIndexes support across full stack

This commit is contained in:
onenewcode authored and GitHub committed 2026-07-01 17:53:09 +08:00
1 parent bb72a58e54
commit 93eeeaa9c6
29 files changed
+1142 -24

No files matched your search

+1
View File
@@ -455,6 +455,7 @@ async fn main() {
.route("/mongo/server-version", post(routes::mongo::server_version))
.route("/mongo/aggregate-documents", post(routes::mongo::aggregate_documents))
.route("/mongo/create-index", post(routes::mongo::create_index))
.route("/mongo/drop-indexes", post(routes::mongo::drop_indexes))
.route("/mongo/insert-document", post(routes::mongo::insert_document))
.route("/mongo/insert-documents", post(routes::mongo::insert_documents))
.route("/mongo/update-document", post(routes::mongo::update_document))
+28
View File
@@ -107,6 +107,16 @@ pub struct MongoCreateIndexRequest {
pub options_json: Option<String>,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MongoDropIndexesRequest {
pub connection_id: String,
pub database: String,
pub collection: String,
pub indexes_json: Option<String>,
pub single: bool,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MongoInsertRequest {
@@ -293,6 +303,24 @@ pub async fn create_index(
Ok(Json(serde_json::json!({ "name": name })))
}
pub async fn drop_indexes(
State(state): State<Arc<WebState>>,
Json(req): Json<MongoDropIndexesRequest>,
) -> Result<Json<serde_json::Value>, AppError> {
ensure_writable(&state.app, &req.connection_id, "Drop indexes").await?;
let result = dbx_core::mongo_ops::mongo_drop_indexes_core(
&state.app,
&req.connection_id,
&req.database,
&req.collection,
req.indexes_json.as_deref(),
req.single,
)
.await
.map_err(AppError)?;
Ok(Json(serde_json::to_value(result).map_err(|e| AppError(e.to_string()))?))
}
pub async fn insert_document(
State(state): State<Arc<WebState>>,
Json(req): Json<MongoInsertRequest>,