mirror of
https://github.com/navidrome/navidrome.git
synced 2024-09-10 11:32:48 +02:00
28 lines
484 B
Go
28 lines
484 B
Go
package repositories
|
|
|
|
import (
|
|
"github.com/deluan/gosonic/models"
|
|
)
|
|
|
|
type Album struct {
|
|
BaseRepository
|
|
}
|
|
|
|
func NewAlbumRepository() *Album {
|
|
r := &Album{}
|
|
r.init("album", &models.Album{})
|
|
return r
|
|
}
|
|
|
|
func (r *Album) Put(m *models.Album) error {
|
|
if m.Id == "" {
|
|
m.Id = r.NewId(m.ArtistId, m.Name)
|
|
}
|
|
return r.saveOrUpdate(m.Id, m)
|
|
}
|
|
|
|
func (r *Album) Get(id string) (*models.Album, error) {
|
|
var rec interface{}
|
|
rec, err := r.readEntity(id)
|
|
return rec.(*models.Album), err
|
|
} |