repository

package
v0.0.0-...-8444db5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceName service.Name = "repository"
)

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func ServiceProvider

func ServiceProvider(highscore HighscoreRepository, user UserRepository, app AppRepository, setting setting.Repository) service.Provider

Types

type App

type App struct {
	ID       AppID
	Manifest *AppManifest
	Order    int
}

type AppID

type AppID string

type AppManifest

type AppManifest struct {
	ID          AppID      `yaml:"id"`
	Version     string     `yaml:"version"`
	Title       string     `yaml:"title"`
	Description string     `yaml:"description"`
	Tags        []string   `yaml:"tags"`
	Options     AppOptions `yaml:"options"`
}

type AppOptions

type AppOptions struct {
	HighscoresEnabled bool `yaml:"highscoresEnabled"`
}

type AppRepository

type AppRepository interface {
	// Override overrides app attributes in the repository
	Override(id AppID, title, description *string, tags []string, order *int) error
	// Save saves an app in the repository
	Save(*App) error
	// List lists apps in the repository
	List() ([]*App, error)
	// Get returns an app by its id
	Get(AppID) (*App, error)
	// Delete removes an app from the repository
	Delete(AppID) error
	// Publish the given app
	Publish(AppID) error
	// Unpublish the given app
	Unpublish(AppID) error
	// isPublished checks if the given app is published
	IsPublished(AppID) (bool, error)
}

type Highscore

type Highscore struct {
	ID           HighscoreID
	Score        int64
	AppID        AppID
	UserID       UserID
	CreationTime time.Time
}

type HighscoreID

type HighscoreID string

type HighscoreRepository

type HighscoreRepository interface {
	Create(appID AppID, userID UserID, score int64) (*Highscore, error)
	Delete(HighscoreID) error
	Get(HighscoreID) (*Highscore, error)
	List() ([]*Highscore, error)
	FindByAppID(appID AppID, userFilters ...UserID) ([]*Highscore, error)
	FindByUserID(userID UserID) ([]*Highscore, error)
}

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func From

func From(container *service.Container) (*Repository, error)

From retrieves the user repository in the given service container

func Must

func Must(container *service.Container) *Repository

Must retrieves the user repository in the given service container or panic otherwise

func NewRepository

func NewRepository(highscore HighscoreRepository, user UserRepository, app AppRepository, setting setting.Repository) *Repository

func (*Repository) App

func (r *Repository) App() AppRepository

func (*Repository) Highscore

func (r *Repository) Highscore() HighscoreRepository

func (*Repository) Setting

func (r *Repository) Setting() setting.Repository

func (*Repository) User

func (r *Repository) User() UserRepository

type User

type User struct {
	ID            UserID
	Nickname      string
	CreationTime  time.Time
	LastSeenTime  time.Time
	LastUserAgent *uasurfer.UserAgent
}

type UserID

type UserID string

type UserRepository

type UserRepository interface {
	Create() (*User, error)
	Save(*User) error
	Get(UserID) (*User, error)
	Delete(UserID) error
	Touch(UserID, string) error
	List() ([]*User, error)
	ListByID(...UserID) ([]*User, error)
}

type UsersByLastSeen

type UsersByLastSeen []*User

func (UsersByLastSeen) Len

func (b UsersByLastSeen) Len() int

func (UsersByLastSeen) Less

func (b UsersByLastSeen) Less(i, j int) bool

func (UsersByLastSeen) Swap

func (b UsersByLastSeen) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL