This commit is contained in:
@@ -55,13 +55,11 @@ func (r *SongRepository) GetAllWithDetails() ([]SongDetail, error) {
|
||||
|
||||
func (r *SongRepository) Get(id int) (Song, error) {
|
||||
var song Song
|
||||
rows, err := r.db.Query("SELECT id, title, artist_id, album_id, duration, media_file_id FROM songs WHERE id = ?", id)
|
||||
err := r.db.QueryRow("SELECT id, title, artist_id, album_id, duration, media_file_id FROM songs WHERE id = ?", id).Scan(
|
||||
&song.ID, &song.Title, &song.ArtistID, &song.AlbumID, &song.Duration, &song.MediaFileID,
|
||||
)
|
||||
if err != nil {
|
||||
return Song{}, err
|
||||
}
|
||||
defer rows.Close()
|
||||
if rows.Next() {
|
||||
rows.Scan(&song.ID, &song.Title, &song.ArtistID, &song.AlbumID, &song.Duration, &song.MediaFileID)
|
||||
}
|
||||
return song, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user