2020-01-14 22:22:34 -05:00
|
|
|
package model
|
2016-03-02 09:33:49 -05:00
|
|
|
|
2020-01-19 15:37:41 -05:00
|
|
|
import (
|
|
|
|
|
"errors"
|
2020-01-19 20:40:18 -05:00
|
|
|
|
|
|
|
|
"github.com/deluan/rest"
|
2020-01-19 15:37:41 -05:00
|
|
|
)
|
2016-03-18 11:33:50 -04:00
|
|
|
|
|
|
|
|
var (
|
2020-01-20 13:35:59 -05:00
|
|
|
ErrNotFound = errors.New("data not found")
|
|
|
|
|
ErrInvalidAuth = errors.New("invalid authentication")
|
2016-03-18 11:33:50 -04:00
|
|
|
)
|
|
|
|
|
|
2020-01-15 23:49:20 -05:00
|
|
|
// Filters use the same operators as Beego ORM: See https://beego.me/docs/mvc/model/query.md#operators
|
|
|
|
|
// Ex: var q = QueryOptions{Filters: Filters{"name__istartswith": "Deluan","age__gt": 25}}
|
|
|
|
|
// All conditions will be ANDed together
|
|
|
|
|
// TODO Implement filter in repositories' methods
|
2016-03-03 22:44:28 -05:00
|
|
|
type QueryOptions struct {
|
2020-01-19 22:36:15 -05:00
|
|
|
Sort string
|
|
|
|
|
Order string
|
|
|
|
|
Max int
|
2020-01-15 23:49:20 -05:00
|
|
|
Offset int
|
2020-01-19 22:36:15 -05:00
|
|
|
Filters map[string]interface{}
|
2016-03-03 22:44:28 -05:00
|
|
|
}
|
2020-01-19 15:37:41 -05:00
|
|
|
|
2020-01-19 20:40:18 -05:00
|
|
|
type ResourceRepository interface {
|
|
|
|
|
rest.Repository
|
|
|
|
|
rest.Persistable
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-19 15:37:41 -05:00
|
|
|
type DataStore interface {
|
|
|
|
|
Album() AlbumRepository
|
|
|
|
|
Artist() ArtistRepository
|
|
|
|
|
MediaFile() MediaFileRepository
|
|
|
|
|
MediaFolder() MediaFolderRepository
|
|
|
|
|
Genre() GenreRepository
|
|
|
|
|
Playlist() PlaylistRepository
|
|
|
|
|
Property() PropertyRepository
|
2020-01-19 22:36:15 -05:00
|
|
|
User() UserRepository
|
2020-01-19 15:37:41 -05:00
|
|
|
|
2020-01-19 20:40:18 -05:00
|
|
|
Resource(model interface{}) ResourceRepository
|
|
|
|
|
|
2020-01-19 15:37:41 -05:00
|
|
|
WithTx(func(tx DataStore) error) error
|
|
|
|
|
}
|