diff options
Diffstat (limited to 'src/database/album.rs')
-rw-r--r-- | src/database/album.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/database/album.rs b/src/database/album.rs index 87054f1..d7ffae0 100644 --- a/src/database/album.rs +++ b/src/database/album.rs @@ -114,18 +114,22 @@ impl DatabaseWrapper { } pub async fn edit_album(&self, data: AlbumPut) -> Result<MySqlQueryResult, sqlx::Error> { - if data.id.is_none() { return Err(sqlx::Error::RowNotFound); } + if data.id.is_none() { + return Err(sqlx::Error::RowNotFound); + } let og_album: Album = match self.select_album_by_id(data.id.as_ref().unwrap()).await { Ok(res) => match res.is_some() { true => res.unwrap(), false => return Err(sqlx::Error::RowNotFound), - } + }, Err(_) => return Err(sqlx::Error::RowNotFound), }; sqlx::query!( "UPDATE album SET name=?, cover=? WHERE id=?", - data.name.unwrap_or(og_album.name.unwrap_or(String::default())), - data.cover.unwrap_or(og_album.cover.unwrap_or(String::default())), + data.name + .unwrap_or(og_album.name.unwrap_or(String::default())), + data.cover + .unwrap_or(og_album.cover.unwrap_or(String::default())), data.id, ) .execute(&self.db_pool) @@ -149,5 +153,4 @@ impl DatabaseWrapper { .execute(&self.db_pool) .await } - } |