More tests, more refactoring, more reflection (ugh)

This commit is contained in:
Deluan
2016-02-29 22:17:54 -05:00
parent 3f72466e24
commit 64b9b3f13a
7 changed files with 179 additions and 44 deletions
+10 -8
View File
@@ -2,7 +2,7 @@ package repositories
import (
"github.com/deluan/gosonic/models"
"errors"
"errors"
)
type ArtistIndex struct {
@@ -11,7 +11,7 @@ type ArtistIndex struct {
func NewArtistIndexRepository() *ArtistIndex {
r := &ArtistIndex{}
r.table = "index"
r.init("index", &models.ArtistIndex{})
return r
}
@@ -22,14 +22,16 @@ func (r *ArtistIndex) Put(m *models.ArtistIndex) error {
return r.saveOrUpdate(m.Id, m)
}
func (r*ArtistIndex) Get(id string) (*models.ArtistIndex, error) {
entity := &models.ArtistIndex{}
err := r.loadEntity(id, entity)
return entity, err
func (r *ArtistIndex) Get(id string) (*models.ArtistIndex, error) {
var rec interface{}
rec, err := r.readEntity(id)
return rec.(*models.ArtistIndex), err
}
func (r*ArtistIndex) GetAll() ([]*models.ArtistIndex, error) {
return nil, errors.New("Not Implemented")
func (r *ArtistIndex) GetAll() ([]models.ArtistIndex, error) {
var indices = make([]models.ArtistIndex, 30)
err := r.loadAll(&indices)
return indices, err
}