diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2025-01-25 20:50:21 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2025-01-25 20:50:21 +0100 |
commit | 57a2df34f4986f1f6062f22804021925afec0419 (patch) | |
tree | f72ba12f40d15248d25235ce711b0aec2a6137a9 /src/database/search_results.rs | |
parent | 8782579e326b55e182d5767a451b8864b3453cce (diff) |
refactor database
Diffstat (limited to 'src/database/search_results.rs')
-rw-r--r-- | src/database/search_results.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/database/search_results.rs b/src/database/search_results.rs new file mode 100644 index 0000000..1468111 --- /dev/null +++ b/src/database/search_results.rs @@ -0,0 +1,36 @@ +use crate::database::DatabaseWrapper; +use crate::database::song::Song; +use crate::database::artist::Artist; +use crate::database::album::Album; + +impl DatabaseWrapper { + pub async fn search_results_by_id( + &self, + id: &str, + ) -> ( + Result<Option<Artist>, sqlx::Error>, + Result<Option<Album>, sqlx::Error>, + Result<Option<Song>, sqlx::Error>, + ) { + ( + self.select_artist_by_id(id).await, + self.select_album_by_id(id).await, + self.select_song_by_id(id).await, + ) + } + + pub async fn search_results_by_name( + &self, + name: &str, + ) -> ( + Result<Vec<Artist>, sqlx::Error>, + Result<Vec<Album>, sqlx::Error>, + Result<Vec<Song>, sqlx::Error>, + ) { + return ( + self.select_artists_by_name(name).await, + self.select_albums_by_name(name).await, + self.select_songs_by_name(name).await, + ); + } +} |