refactor: consolidate query executions into two functions queryOne and queryAll
This commit is contained in:
@@ -23,11 +23,7 @@ func NewGenreRepository(ctx context.Context, o orm.Ormer) model.GenreRepository
|
||||
func (r genreRepository) GetAll() (model.Genres, error) {
|
||||
sq := Select("genre as name", "count(distinct album_id) as album_count", "count(distinct id) as song_count").
|
||||
From("media_file").GroupBy("genre")
|
||||
sql, args, err := r.toSql(sq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := model.Genres{}
|
||||
_, err = r.ormer.Raw(sql, args).QueryRows(&res)
|
||||
err := r.queryAll(sq, &res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user