|
|
@ -7,7 +7,10 @@ use axum::middleware; |
|
|
|
use axum::routing::get; |
|
|
|
use axum::routing::get; |
|
|
|
use axum::Router; |
|
|
|
use axum::Router; |
|
|
|
use futures::stream::TryStreamExt; |
|
|
|
use futures::stream::TryStreamExt; |
|
|
|
|
|
|
|
use futures::StreamExt; |
|
|
|
|
|
|
|
use mongodb::bson::doc; |
|
|
|
use mongodb::bson::Document; |
|
|
|
use mongodb::bson::Document; |
|
|
|
|
|
|
|
use mongodb::options::FindOptions; |
|
|
|
|
|
|
|
|
|
|
|
use crate::auth; |
|
|
|
use crate::auth; |
|
|
|
use crate::State; |
|
|
|
use crate::State; |
|
|
@ -32,9 +35,20 @@ pub fn router(state: Arc<State>, ci_usr: String, ci_pwd: String, ci_role: String |
|
|
|
|
|
|
|
|
|
|
|
async fn all_cases_on_collection(Path(collection): Path<String>, state: Arc<State>) -> String { |
|
|
|
async fn all_cases_on_collection(Path(collection): Path<String>, state: Arc<State>) -> String { |
|
|
|
let collection = state.db.collection::<Document>(&collection); |
|
|
|
let collection = state.db.collection::<Document>(&collection); |
|
|
|
let mut cursor = collection.find(None, None).await.unwrap(); |
|
|
|
let options = FindOptions::builder() |
|
|
|
while let Some(record) = cursor.try_next().await.unwrap() { |
|
|
|
.projection(doc! { "caseID": 1 }) |
|
|
|
tracing::debug!("{:?}", record.get_str("caseID")); |
|
|
|
.build(); |
|
|
|
} |
|
|
|
let cursor = collection.find(None, options).await.unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let result = cursor |
|
|
|
|
|
|
|
.map(|r| r.unwrap().get_str("caseID").unwrap().to_lowercase()) |
|
|
|
|
|
|
|
.collect::<Vec<String>>() |
|
|
|
|
|
|
|
.await; |
|
|
|
|
|
|
|
// while let Some(record) = cursor.try_next().await.unwrap() {
|
|
|
|
|
|
|
|
// tracing::debug!("{:?}", record.get_str("caseID").unwrap());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tracing::debug!("Cases: {:?}", result); |
|
|
|
|
|
|
|
|
|
|
|
format!("Cases!") |
|
|
|
format!("Cases!") |
|
|
|
} |
|
|
|
} |
|
|
|