diff options
Diffstat (limited to 'src/database.rs')
-rw-r--r-- | src/database.rs | 18 |
1 files changed, 9 insertions, 9 deletions
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<Vec<Song>, sqlx::Error> { + pub async fn select_song_by_id(&self, id: &str) -> Result<Option<Song>, 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<Vec<Album>, sqlx::Error> { + pub async fn select_album_by_id(&self, id: &str) -> Result<Option<Album>, 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<Vec<Artist>, sqlx::Error> { + pub async fn select_artist_by_id(&self, id: &str) -> Result<Option<Artist>, 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<Vec<Artist>, sqlx::Error>, - Result<Vec<Album>, sqlx::Error>, - Result<Vec<Song>, sqlx::Error>, + Result<Option<Artist>, sqlx::Error>, + Result<Option<Album>, sqlx::Error>, + Result<Option<Song>, sqlx::Error>, ) { return ( self.select_artist_by_id(id).await, |