mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
implement delete documents
This commit is contained in:
parent
181eaf95f5
commit
ae5581d37c
3 changed files with 31 additions and 24 deletions
|
@ -229,21 +229,20 @@ async fn delete_documents(
|
|||
path: web::Path<IndexParam>,
|
||||
body: web::Json<Vec<Value>>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
todo!()
|
||||
//let ids = body
|
||||
//.iter()
|
||||
//.map(|v| v.as_str().map(String::from).unwrap_or_else(|| v.to_string()))
|
||||
//.collect();
|
||||
let ids = body
|
||||
.iter()
|
||||
.map(|v| v.as_str().map(String::from).unwrap_or_else(|| v.to_string()))
|
||||
.collect();
|
||||
|
||||
//match data.delete_documents(path.index_uid.clone(), ids).await {
|
||||
//Ok(result) => {
|
||||
//let json = serde_json::to_string(&result).unwrap();
|
||||
//Ok(HttpResponse::Ok().body(json))
|
||||
//}
|
||||
//Err(e) => {
|
||||
//Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
//}
|
||||
//}
|
||||
match data.delete_documents(path.index_uid.clone(), ids).await {
|
||||
Ok(result) => {
|
||||
let json = serde_json::to_string(&result).unwrap();
|
||||
Ok(HttpResponse::Ok().body(json))
|
||||
}
|
||||
Err(e) => {
|
||||
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[delete("/indexes/{index_uid}/documents", wrap = "Authentication::Private")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue