mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
fix requested changes
This commit is contained in:
parent
ea308eb798
commit
36c7fd0cf1
12 changed files with 68 additions and 63 deletions
|
@ -157,13 +157,13 @@ async fn create_index(
|
|||
));
|
||||
}
|
||||
|
||||
let uid = match body.uid.clone() {
|
||||
let uid = match &body.uid {
|
||||
Some(uid) => {
|
||||
if uid
|
||||
.chars()
|
||||
.all(|x| x.is_ascii_alphanumeric() || x == '-' || x == '_')
|
||||
{
|
||||
uid
|
||||
uid.to_owned()
|
||||
} else {
|
||||
return Err(ResponseError::InvalidIndexUid);
|
||||
}
|
||||
|
@ -183,8 +183,8 @@ async fn create_index(
|
|||
|
||||
let mut writer = data.db.main_write_txn()?;
|
||||
|
||||
let name = body.name.clone().unwrap_or(uid.clone());
|
||||
created_index.main.put_name(&mut writer, &name)?;
|
||||
let name = body.name.as_ref().unwrap_or(&uid);
|
||||
created_index.main.put_name(&mut writer, name)?;
|
||||
|
||||
let created_at = created_index
|
||||
.main
|
||||
|
@ -208,7 +208,7 @@ async fn create_index(
|
|||
writer.commit()?;
|
||||
|
||||
Ok(HttpResponse::Created().json(IndexResponse {
|
||||
name,
|
||||
name: name.to_string(),
|
||||
uid,
|
||||
created_at,
|
||||
updated_at,
|
||||
|
@ -246,8 +246,8 @@ async fn update_index(
|
|||
|
||||
let mut writer = data.db.main_write_txn()?;
|
||||
|
||||
if let Some(name) = body.name.clone() {
|
||||
index.main.put_name(&mut writer, &name)?;
|
||||
if let Some(name) = &body.name {
|
||||
index.main.put_name(&mut writer, name)?;
|
||||
}
|
||||
|
||||
if let Some(id) = body.primary_key.clone() {
|
||||
|
@ -314,7 +314,7 @@ async fn delete_index(
|
|||
Ok(HttpResponse::NoContent().finish())
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
#[derive(Deserialize)]
|
||||
struct UpdateParam {
|
||||
index_uid: String,
|
||||
update_id: u64,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue