From 57a2df34f4986f1f6062f22804021925afec0419 Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Sat, 25 Jan 2025 20:50:21 +0100 Subject: refactor database --- src/database/search_results.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/database/search_results.rs (limited to 'src/database/search_results.rs') 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, sqlx::Error>, + Result, sqlx::Error>, + Result, 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, sqlx::Error>, + Result, sqlx::Error>, + Result, sqlx::Error>, + ) { + return ( + self.select_artists_by_name(name).await, + self.select_albums_by_name(name).await, + self.select_songs_by_name(name).await, + ); + } +} -- cgit v1.2.3