Documentation ¶
Index ¶
- Variables
- type DB
- type Entry
- type Leaderboard
- type MemDB
- func (d *MemDB) CreateEntry(leaderboardId uuid.UUID, name string, fieldValues map[string]int) (*Entry, error)
- func (d *MemDB) CreateLeaderboard(name string, fieldNames []string, entries map[uuid.UUID]*Entry) *Leaderboard
- func (d *MemDB) ReadEntries(leaderboardId uuid.UUID, sortKey, order string) ([]*Entry, error)
- func (d *MemDB) ReadLeaderboard(id uuid.UUID) *Leaderboard
- func (d *MemDB) UpdateEntry(leaderboardId uuid.UUID, entryId uuid.UUID, fieldValues map[string]int) (*Entry, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrLeaderboardNotFound = errors.New("leaderboard not found") ErrLeaderboardInvalidFieldName = errors.New("invalid field name") ErrLeaderboardHasNoEntries = errors.New("leaderboard has no entries") ErrEntryNotFound = errors.New("entry not found") ErrEntryInvalidSortKey = errors.New("invalid sort key") )
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { // Leaderboard operations. CreateLeaderboard(name string, fieldNames []string, entries map[uuid.UUID]*Entry) *Leaderboard ReadLeaderboard(id uuid.UUID) *Leaderboard // Entry operations. CreateEntry(leaderboardId uuid.UUID, name string, fieldValues map[string]int) (*Entry, error) UpdateEntry(leaderboardId uuid.UUID, entryId uuid.UUID, fieldValues map[string]int) (*Entry, error) ReadEntries(leaderboardId uuid.UUID, sortKey, order string) ([]*Entry, error) }
type Entry ¶
type Leaderboard ¶
type Leaderboard struct { ID uuid.UUID `json:"id"` Name string `json:"name"` FieldNames []string `json:"fieldNames"` Entries map[uuid.UUID]*Entry `json:"entries,omitempty"` }
func NewLeaderboard ¶
func (*Leaderboard) HasFieldName ¶
func (l *Leaderboard) HasFieldName(name string) bool
type MemDB ¶
type MemDB struct{}
func (*MemDB) CreateEntry ¶
func (*MemDB) CreateLeaderboard ¶
func (*MemDB) ReadEntries ¶
func (*MemDB) ReadLeaderboard ¶
func (d *MemDB) ReadLeaderboard(id uuid.UUID) *Leaderboard
Click to show internal directories.
Click to hide internal directories.