feat(mongodb): rename collections from sidebar

This commit is contained in:
onenewcode authored and GitHub committed 2026-07-21 17:08:27 +08:00
1 parent 809500fd52
commit 9a83b46f00
26 files changed
+1105 -93

No files matched your search

+1
View File
@@ -450,6 +450,7 @@ async fn main() {
.route("/mongo/create-database", post(routes::mongo::create_database))
.route("/mongo/drop-database", post(routes::mongo::drop_database))
.route("/mongo/drop-collection", post(routes::mongo::drop_collection))
.route("/mongo/rename-collection", post(routes::mongo::rename_collection))
.route("/document-store/list-databases", post(routes::document_store::list_databases))
.route("/document-store/list-collections", post(routes::document_store::list_collections))
.route("/document-store/find-documents", post(routes::document_store::find_documents))
+29
View File
@@ -77,6 +77,15 @@ pub struct MongoCollectionNameRequest {
pub collection: String,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MongoRenameCollectionRequest {
pub connection_id: String,
pub database: String,
pub collection: String,
pub new_name: String,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MongoFindRequest {
@@ -350,6 +359,26 @@ pub async fn drop_collection(
Ok(Json(serde_json::json!({ "ok": true })))
}
pub async fn rename_collection(
State(state): State<Arc<WebState>>,
headers: HeaderMap,
Json(req): Json<MongoRenameCollectionRequest>,
) -> Result<Json<serde_json::Value>, AppError> {
super::mcp_policy::ensure_dangerous_write(&state, &headers, &req.connection_id, &req.database, "Rename collection")
.await?;
ensure_writable(&state.app, &req.connection_id, "Rename collection").await?;
dbx_core::mongo_ops::mongo_rename_collection_core(
&state.app,
&req.connection_id,
&req.database,
&req.collection,
&req.new_name,
)
.await
.map_err(AppError)?;
Ok(Json(serde_json::json!({ "ok": true })))
}
pub async fn find_documents(
State(state): State<Arc<WebState>>,
headers: HeaderMap,