Converted all collections from repositories to *collections
This commit is contained in:
@@ -29,16 +29,16 @@ func (r *albumRepository) Get(id string) (*domain.Album, error) {
|
||||
return rec.(*domain.Album), err
|
||||
}
|
||||
|
||||
func (r *albumRepository) FindByArtist(artistId string) (domain.Albums, error) {
|
||||
func (r *albumRepository) FindByArtist(artistId string) (*domain.Albums, error) {
|
||||
var as = make(domain.Albums, 0)
|
||||
err := r.loadChildren("artist", artistId, &as, domain.QueryOptions{SortBy: "Year"})
|
||||
return as, err
|
||||
return &as, err
|
||||
}
|
||||
|
||||
func (r *albumRepository) GetAll(options domain.QueryOptions) (domain.Albums, error) {
|
||||
func (r *albumRepository) GetAll(options domain.QueryOptions) (*domain.Albums, error) {
|
||||
var as = make(domain.Albums, 0)
|
||||
err := r.loadAll(&as, options)
|
||||
return as, err
|
||||
return &as, err
|
||||
}
|
||||
|
||||
func (r *albumRepository) PurgeInactive(active *domain.Albums) error {
|
||||
|
||||
@@ -2,8 +2,9 @@ package persistence
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"sort"
|
||||
|
||||
"github.com/deluan/gosonic/domain"
|
||||
)
|
||||
|
||||
type artistIndexRepository struct {
|
||||
@@ -30,10 +31,10 @@ func (r *artistIndexRepository) Get(id string) (*domain.ArtistIndex, error) {
|
||||
return rec.(*domain.ArtistIndex), err
|
||||
}
|
||||
|
||||
func (r *artistIndexRepository) GetAll() (domain.ArtistIndexes, error) {
|
||||
func (r *artistIndexRepository) GetAll() (*domain.ArtistIndexes, error) {
|
||||
var indices = make(domain.ArtistIndexes, 0)
|
||||
err := r.loadAll(&indices, domain.QueryOptions{Alpha: true})
|
||||
return indices, err
|
||||
return &indices, err
|
||||
}
|
||||
|
||||
var _ domain.ArtistIndexRepository = (*artistIndexRepository)(nil)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/tests"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIndexRepository(t *testing.T) {
|
||||
@@ -56,7 +57,7 @@ func TestIndexRepository(t *testing.T) {
|
||||
So(indices, ShouldHaveLength, 4)
|
||||
})
|
||||
Convey("And the values should be retrieved", func() {
|
||||
for _, e := range indices {
|
||||
for _, e := range *indices {
|
||||
So(e.Id, ShouldBeIn, []string{"1", "2", "3", "4"})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -36,11 +36,11 @@ func (r *mediaFileRepository) Get(id string) (*domain.MediaFile, error) {
|
||||
return mf, nil
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) FindByAlbum(albumId string) (domain.MediaFiles, error) {
|
||||
func (r *mediaFileRepository) FindByAlbum(albumId string) (*domain.MediaFiles, error) {
|
||||
var mfs = make(domain.MediaFiles, 0)
|
||||
err := r.loadChildren("album", albumId, &mfs)
|
||||
sort.Sort(mfs)
|
||||
return mfs, err
|
||||
return &mfs, err
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) PurgeInactive(active *domain.MediaFiles) error {
|
||||
|
||||
@@ -13,11 +13,11 @@ func NewMediaFolderRepository() domain.MediaFolderRepository {
|
||||
return &mediaFolderRepository{}
|
||||
}
|
||||
|
||||
func (*mediaFolderRepository) GetAll() (domain.MediaFolders, error) {
|
||||
func (*mediaFolderRepository) GetAll() (*domain.MediaFolders, error) {
|
||||
mediaFolder := domain.MediaFolder{Id: "0", Name: "iTunes Library", Path: beego.AppConfig.String("musicFolder")}
|
||||
result := make(domain.MediaFolders, 1)
|
||||
result[0] = mediaFolder
|
||||
return result, nil
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
var _ domain.MediaFolderRepository = (*mediaFolderRepository)(nil)
|
||||
var _ domain.MediaFolderRepository = (*mediaFolderRepository)(nil)
|
||||
|
||||
Reference in New Issue
Block a user