11 files changed
+544
-2
No files matched your search
@@ -623,6 +623,7 @@ async fn main() {
|
||||
.route("/document-store/delete-document", post(routes::document_store::delete_document))
|
||||
.route("/mongo/find-documents", post(routes::mongo::find_documents))
|
||||
.route("/mongo/parse-shell-command", post(routes::mongo::parse_shell_command))
|
||||
.route("/mongo/explain-find", post(routes::mongo::explain_find))
|
||||
.route("/mongo/find-one", post(routes::mongo::find_one))
|
||||
.route("/mongo/count-documents", post(routes::mongo::count_documents))
|
||||
.route("/mongo/server-version", post(routes::mongo::server_version))
|
||||
|
||||
@@ -101,6 +101,22 @@ pub struct MongoFindRequest {
|
||||
pub execution_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MongoFindExplainRequest {
|
||||
pub connection_id: String,
|
||||
pub database: String,
|
||||
pub collection: String,
|
||||
pub skip: Option<u64>,
|
||||
pub limit: Option<i64>,
|
||||
pub filter: Option<String>,
|
||||
pub projection: Option<String>,
|
||||
pub sort: Option<String>,
|
||||
pub collation: Option<String>,
|
||||
pub verbosity: Option<String>,
|
||||
pub execution_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MongoFindOneRequest {
|
||||
@@ -409,6 +425,34 @@ pub async fn find_documents(
|
||||
Ok(Json(serde_json::to_value(result).map_err(|e| AppError::from(e.to_string()))?))
|
||||
}
|
||||
|
||||
pub async fn explain_find(
|
||||
State(state): State<Arc<WebState>>,
|
||||
headers: HeaderMap,
|
||||
Json(req): Json<MongoFindExplainRequest>,
|
||||
) -> Result<Json<serde_json::Value>, AppError> {
|
||||
super::mcp_policy::ensure_scope(&state, &headers, &req.connection_id).await?;
|
||||
let verbosity = req.verbosity.as_deref().unwrap_or("queryPlanner");
|
||||
let result = run_cancellable(
|
||||
&state,
|
||||
req.execution_id.clone(),
|
||||
dbx_core::mongo_ops::mongo_explain_find_core(
|
||||
&state.app,
|
||||
&req.connection_id,
|
||||
&req.database,
|
||||
&req.collection,
|
||||
req.skip.unwrap_or(0),
|
||||
req.limit.unwrap_or(100),
|
||||
req.filter.as_deref(),
|
||||
req.projection.as_deref(),
|
||||
req.sort.as_deref(),
|
||||
req.collation.as_deref(),
|
||||
verbosity,
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn find_one(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<MongoFindOneRequest>,
|
||||
|
||||
Reference in new issue
Block a user