mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 04:57:37 +03:00
Big Refactor:
- Create model.DataStore, with provision for transactions - Change all layers dependencies on repositories to use DataStore - Implemented persistence.SQLStore - Removed iTunes Bridge/Importer support
This commit is contained in:
parent
40186f7e10
commit
67eeb218c4
47 changed files with 389 additions and 1621 deletions
|
@ -14,27 +14,28 @@ type propertyRepository struct {
|
|||
sqlRepository
|
||||
}
|
||||
|
||||
func NewPropertyRepository() model.PropertyRepository {
|
||||
func NewPropertyRepository(o orm.Ormer) model.PropertyRepository {
|
||||
r := &propertyRepository{}
|
||||
r.ormer = o
|
||||
r.tableName = "property"
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *propertyRepository) Put(id string, value string) error {
|
||||
p := &property{ID: id, Value: value}
|
||||
num, err := Db().Update(p)
|
||||
num, err := r.ormer.Update(p)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if num == 0 {
|
||||
_, err = Db().Insert(p)
|
||||
_, err = r.ormer.Insert(p)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *propertyRepository) Get(id string) (string, error) {
|
||||
p := &property{ID: id}
|
||||
err := Db().Read(p)
|
||||
err := r.ormer.Read(p)
|
||||
if err == orm.ErrNoRows {
|
||||
return "", model.ErrNotFound
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue