repo

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Count

type Count struct {
	Delta    int16     `db:"delta"`
	PlayerID uuid.UUID `db:"player_id"`
}

Count describes structure of count_history table.

type Player

type Player struct {
	ID       uuid.UUID `db:"id"`
	TGUserID int64     `db:"tg_user_id"`
}

Player describes structure of users table.

type Repo

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

Repo - db communications.

func New

func New(db *sqlx.DB) *Repo

New creates new DB instance with initialized caches.

func (*Repo) CreateUserFromTG

func (r *Repo) CreateUserFromTG(ctx context.Context, telegramUserID int64) (uuid.UUID, error)

CreateUserFromTG creates new user from Telegram and returning its id.

func (*Repo) FindUserByTelegramID

func (r *Repo) FindUserByTelegramID(ctx context.Context, telegramID int64) (*Player, error)

FindUserByTelegramID search for user by telegram ID.

func (*Repo) GetPlayerCount

func (r *Repo) GetPlayerCount(ctx context.Context, id uuid.UUID) (int32, error)

GetPlayerCount returns player count.

func (*Repo) ListPlayers added in v0.1.1

func (r *Repo) ListPlayers(ctx context.Context) ([]Player, error)

ListPlayers lists existing players.

func (*Repo) UpdatePlayerCount

func (r *Repo) UpdatePlayerCount(ctx context.Context, playerID uuid.UUID, delta int16) error

UpdatePlayerCount updates player point count.

Jump to

Keyboard shortcuts

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