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
@@ -0,0 +1,42 @@
package db_storm
import (
"github.com/asdine/storm"
"github.com/cloudsonic/sonic-server/domain"
)
const propertyBucket = "Property"
type propertyRepository struct {
}
func NewPropertyRepository() domain.PropertyRepository {
r := &propertyRepository{}
return r
}
func (r *propertyRepository) Put(id string, value string) error {
return Db().Set(propertyBucket, id, value)
}
func (r *propertyRepository) Get(id string) (string, error) {
var value string
err := Db().Get(propertyBucket, id, &value)
if err == storm.ErrNotFound {
return value, domain.ErrNotFound
}
return value, err
}
func (r *propertyRepository) DefaultGet(id string, defaultValue string) (string, error) {
value, err := r.Get(id)
if err == domain.ErrNotFound {
return defaultValue, nil
}
if err != nil {
return defaultValue, err
}
return value, nil
}
var _ domain.PropertyRepository = (*propertyRepository)(nil)