From 58515ddfecd3701112616c33ad4879dae4b38ffd Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Mon, 20 Jan 2025 22:15:14 +0100 Subject: save before disaster --- src/database.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/database.rs') diff --git a/src/database.rs b/src/database.rs index 32b1de7..eff3f0e 100644 --- a/src/database.rs +++ b/src/database.rs @@ -61,7 +61,7 @@ impl DatabaseWrapper { .await; } - pub async fn select_song_by_id(&self, id: &str) -> Result, sqlx::Error> { + pub async fn select_song_by_id(&self, id: &str) -> Result, sqlx::Error> { return sqlx::query_as!( Song, "SELECT song.name, song.lyrics, song.id, @@ -74,7 +74,7 @@ impl DatabaseWrapper { ", id, ) - .fetch_all(&self.db_pool) + .fetch_optional(&self.db_pool) .await; } @@ -143,7 +143,7 @@ impl DatabaseWrapper { .await; } - pub async fn select_album_by_id(&self, id: &str) -> Result, sqlx::Error> { + pub async fn select_album_by_id(&self, id: &str) -> Result, sqlx::Error> { return sqlx::query_as!( Album, "SELECT album.name, album.id, @@ -153,7 +153,7 @@ impl DatabaseWrapper { WHERE album.id=?", id, ) - .fetch_all(&self.db_pool) + .fetch_optional(&self.db_pool) .await; } @@ -200,7 +200,7 @@ impl DatabaseWrapper { .await; } - pub async fn select_artist_by_id(&self, id: &str) -> Result, sqlx::Error> { + pub async fn select_artist_by_id(&self, id: &str) -> Result, sqlx::Error> { return sqlx::query_as!( Artist, "SELECT name, id @@ -208,7 +208,7 @@ impl DatabaseWrapper { WHERE id = ?", id, ) - .fetch_all(&self.db_pool) + .fetch_optional(&self.db_pool) .await; } @@ -244,9 +244,9 @@ impl DatabaseWrapper { &self, id: &str, ) -> ( - Result, sqlx::Error>, - Result, sqlx::Error>, - Result, sqlx::Error>, + Result, sqlx::Error>, + Result, sqlx::Error>, + Result, sqlx::Error>, ) { return ( self.select_artist_by_id(id).await, -- cgit v1.2.3