Renamed persistence packages

This commit is contained in:
Deluan
2020-01-10 19:41:35 -05:00
committed by Deluan Quintão
parent a1d837cb9b
commit 11f4505925
34 changed files with 85 additions and 85 deletions
+44
View File
@@ -0,0 +1,44 @@
package db_storm
import (
"github.com/cloudsonic/sonic-server/domain"
)
// This is used to isolate Storm's struct tags from the domain, to keep it agnostic of persistence details
type _Artist struct {
ID string
Name string `storm:"index"`
AlbumCount int
}
type artistRepository struct {
stormRepository
}
func NewArtistRepository() domain.ArtistRepository {
r := &artistRepository{}
r.init(&_Artist{})
return r
}
func (r *artistRepository) Put(a *domain.Artist) error {
ta := _Artist(*a)
return Db().Save(&ta)
}
func (r *artistRepository) Get(id string) (*domain.Artist, error) {
ta := &_Artist{}
err := r.getByID(id, ta)
if err != nil {
return nil, err
}
a := domain.Artist(*ta)
return &a, nil
}
func (r *artistRepository) PurgeInactive(activeList domain.Artists) ([]string, error) {
return r.purgeInactive(activeList)
}
var _ domain.ArtistRepository = (*artistRepository)(nil)
var _ = domain.Artist(_Artist{})