Files
navidrome/repositories/base_repository.go
T
2016-02-28 14:21:12 -05:00

30 lines
546 B
Go

package repositories
import (
"fmt"
"crypto/md5"
"strings"
)
type BaseRepository struct {
key string // TODO Rename to 'table'
}
func (r *BaseRepository) NewId(fields ...string) string {
s := fmt.Sprintf("%s\\%s", strings.ToUpper(r.key), strings.Join(fields, ""))
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
}
func (r *BaseRepository) CountAll() (int, error) {
return count(r.key)
}
func (r *BaseRepository) saveOrUpdate(id string, rec interface{}) error {
return saveStruct(r.key, id, rec)
}
func (r *BaseRepository) Dump() {
}