restore update documents

This commit is contained in:
mpostma 2021-03-04 15:10:58 +01:00
parent 581dcd5735
commit 181eaf95f5
No known key found for this signature in database
GPG Key ID: CBC8A7C1D7A28C3A

View File

@ -199,26 +199,25 @@ async fn update_documents(
params: web::Query<UpdateDocumentsQuery>,
body: web::Payload,
) -> Result<HttpResponse, ResponseError> {
todo!()
//let addition_result = data
//.add_documents(
//path.into_inner().index_uid,
//IndexDocumentsMethod::UpdateDocuments,
//UpdateFormat::Json,
//body,
//params.primary_key.clone(),
//).await;
let addition_result = data
.add_documents(
path.into_inner().index_uid,
IndexDocumentsMethod::UpdateDocuments,
UpdateFormat::Json,
body,
params.primary_key.clone(),
).await;
//match addition_result {
//Ok(update) => {
//let value = serde_json::to_string(&update).unwrap();
//let response = HttpResponse::Ok().body(value);
//Ok(response)
//}
//Err(e) => {
//Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
//}
//}
match addition_result {
Ok(update) => {
let value = serde_json::to_string(&update).unwrap();
let response = HttpResponse::Ok().body(value);
Ok(response)
}
Err(e) => {
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
}
}
}
#[post(