Create initial user if User table is empty. Also make model.QueryOptions compatible with rest.QueryOptions

This commit is contained in:
Deluan 2020-01-19 22:36:15 -05:00
parent 2ab0cecd48
commit 491bfb1f69
11 changed files with 130 additions and 38 deletions

View file

@ -14,14 +14,12 @@ var (
// Ex: var q = QueryOptions{Filters: Filters{"name__istartswith": "Deluan","age__gt": 25}}
// All conditions will be ANDed together
// TODO Implement filter in repositories' methods
type Filters map[string]interface{}
type QueryOptions struct {
SortBy string
Desc bool
Sort string
Order string
Max int
Offset int
Size int
Filters Filters
Filters map[string]interface{}
}
type ResourceRepository interface {
@ -37,6 +35,7 @@ type DataStore interface {
Genre() GenreRepository
Playlist() PlaylistRepository
Property() PropertyRepository
User() UserRepository
Resource(model interface{}) ResourceRepository

View file

@ -12,3 +12,9 @@ type User struct {
CreatedAt time.Time
UpdatedAt time.Time
}
type UserRepository interface {
CountAll(...QueryOptions) (int64, error)
Get(id string) (*User, error)
Put(*User) error
}