summaryrefslogtreecommitdiff
path: root/src/database.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/database.rs')
-rw-r--r--src/database.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/database.rs b/src/database.rs
index 299bd8d..a9daa7f 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: String) -> Result<Vec<Song>, sqlx::Error> {
+ pub async fn select_song_by_id(&self, id: &str) -> Result<Vec<Song>, sqlx::Error> {
return sqlx::query_as!(
Song,
"SELECT song.name, song.lyrics, song.id,
@@ -78,7 +78,7 @@ impl DatabaseWrapper {
.await;
}
- pub async fn select_songs_by_album(&self, album_id: String) -> Result<Vec<Song>, sqlx::Error> {
+ pub async fn select_songs_by_album(&self, album_id: &str) -> Result<Vec<Song>, sqlx::Error> {
return sqlx::query_as!(
Song,
"SELECT song.name, song.lyrics, song.id,
@@ -97,7 +97,7 @@ impl DatabaseWrapper {
pub async fn select_songs_by_artist(
&self,
- artist_id: String,
+ artist_id: &str,
) -> Result<Vec<Song>, sqlx::Error> {
return sqlx::query_as!(
Song,
@@ -115,8 +115,9 @@ impl DatabaseWrapper {
.await;
}
- pub async fn select_songs_by_name(&self, name_raw: String) -> Result<Vec<Song>, sqlx::Error> {
+ pub async fn select_songs_by_name(&self, name_raw: &str) -> Result<Vec<Song>, sqlx::Error> {
let name: String = format!("{}{}{}", "%", name_raw, "%");
+ println!("ERROR HUNTING: {}", name);
return sqlx::query_as!(
Song,
"SELECT song.name, song.lyrics, song.id,
@@ -145,7 +146,7 @@ impl DatabaseWrapper {
.await;
}
- pub async fn select_album_by_id(&self, id: String) -> Result<Vec<Album>, sqlx::Error> {
+ pub async fn select_album_by_id(&self, id: &str) -> Result<Vec<Album>, sqlx::Error> {
return sqlx::query_as!(
Album,
"SELECT album.name, album.id,
@@ -159,7 +160,7 @@ impl DatabaseWrapper {
.await;
}
- pub async fn select_albums_by_name(&self, name_raw: String) -> Result<Vec<Album>, sqlx::Error> {
+ pub async fn select_albums_by_name(&self, name_raw: &str) -> Result<Vec<Album>, sqlx::Error> {
let name : String = format!("{}{}{}", "%", name_raw, "%");
return sqlx::query_as!(
Album,
@@ -175,7 +176,7 @@ impl DatabaseWrapper {
.await;
}
- pub async fn select_albums_by_artist_id(&self, artist_id: String) -> Result<Vec<Album>, sqlx::Error> {
+ pub async fn select_albums_by_artist(&self, artist_id: &str) -> Result<Vec<Album>, sqlx::Error> {
return sqlx::query_as!(
Album,
"SELECT album.name, album.id,
@@ -200,7 +201,7 @@ impl DatabaseWrapper {
.await;
}
- pub async fn select_artist_by_id(&self, id: String) -> Result<Vec<Artist>, sqlx::Error> {
+ pub async fn select_artist_by_id(&self, id: &str) -> Result<Vec<Artist>, sqlx::Error> {
return sqlx::query_as!(
Artist,
"SELECT name, id
@@ -213,13 +214,14 @@ impl DatabaseWrapper {
.await;
}
- pub async fn select_artists_by_name(&self, name_raw: String) -> Result<Vec<Artist>, sqlx::Error> {
+ pub async fn select_artists_by_name(&self, name_raw: &str) -> Result<Vec<Artist>, sqlx::Error> {
let name : String = format!("{}{}{}", "%", name_raw, "%");
+ println!("ERROR HUNTING: {}", name);
return sqlx::query_as!(
Artist,
"SELECT name, id
FROM artist
- WHERE name = ?"
+ WHERE name LIKE ?"
,
name,
)