Documentation ¶
Index ¶
- func CountGameMoves(filter string) (int, error)
- func CountGames(filter string) (int, error)
- func CountPlayers(filter string) (int, error)
- func CreateGameMove(gameId int64, playerId int64, move string) error
- func DeleteGame(id int64) error
- func DeletePlayer(id int64) error
- func FindInactiveGames() (*[]Game, error)
- func PrepareQueryParams(filter string, page int, size int, sort string) (string, string, string, []any)
- func QueryGameMoves(filter string, page int, size int, sort string) (*[]GameMove, error)
- func QueryGames(filter string, page int, size int, sort string) (*[]Game, error)
- func QueryPlayers(filter string, page int, size int, sort string) (*[]Player, error)
- func RevokeAccessToken(token string) error
- func SqlDateFormat(dt sql.NullTime) interface{}
- func UpdateGame(game *Game) error
- func UpdateGamePlayerUsername(playerId int64, username string) error
- func UpdatePlayer(player *Player) error
- type AccessToken
- type Game
- type GameMove
- type Player
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountGameMoves ¶
func CountGames ¶
func CountPlayers ¶
func DeleteGame ¶
func DeletePlayer ¶
func FindInactiveGames ¶
func PrepareQueryParams ¶
func PrepareQueryParams(filter string, page int, size int, sort string) (string, string, string, []any)
PrepareQueryParams returns where, sort, order, and args parameters used for further building of SQL query. If filter is empty the where param will be an empty string. The filter must match following pattern: (key1)(operator1)(value1);(and|or|not)?;(key2)(operator2)(value2)...
Supported operators: = (equals), != (not equals), <= (less than or equal), >= (greater than or equal), < (less than), > (greater than), ~ (like), !~ (not like), -> (in), !-> (not in)
Example filter: id>=1;or;username=someName;and;startedAt!=null
Returned args will contain at least two values at the end: limit and offset. If where query needs additional parameters, they will be added in args slice.
func QueryGameMoves ¶
func QueryPlayers ¶
func RevokeAccessToken ¶
func SqlDateFormat ¶
func UpdateGame ¶
func UpdatePlayer ¶
Types ¶
type AccessToken ¶
type AccessToken struct { Id int64 PlayerId int64 Token string CreatedAt time.Time UpdatedAt time.Time }
func CreateAccessToken ¶
func CreateAccessToken(playerId int64) (*AccessToken, error)
func FindAccessToken ¶
func FindAccessToken(token string) (*AccessToken, error)
type Game ¶
type Game struct { Id int64 Name string PasswordHash sql.NullString TurnDurationSeconds sql.NullInt32 WhitePlayerId sql.NullInt64 WhitePlayerUsername sql.NullString BlackPlayerId sql.NullInt64 BlackPlayerUsername sql.NullString CreatorId sql.NullInt64 WinnerId sql.NullInt64 Tiles string InProgress bool LastMovePlayedAt sql.NullTime StartedAt sql.NullTime EndedAt sql.NullTime CreatedAt time.Time UpdatedAt time.Time }
func CreateGame ¶
func FindGameById ¶
func (*Game) FormatCreatedAt ¶
func (*Game) FormatEndedAt ¶
func (*Game) FormatLastMovePlayedAt ¶
func (*Game) FormatStartedAt ¶
func (*Game) FormatUpdatedAt ¶
type GameMove ¶
type GameMove struct { Id int64 GameId int64 PlayerId sql.NullInt64 Move string CreatedAt time.Time UpdatedAt time.Time }
func (*GameMove) FormatCreatedAt ¶
func (*GameMove) FormatUpdatedAt ¶
type Player ¶
type Player struct { Id int64 Username string PasswordHash string Wins int32 Losses int32 Draws int32 Rate float32 Elo int32 LastPlayedAt sql.NullTime IsPlaying bool CreatedAt time.Time UpdatedAt time.Time }
func FindPlayerById ¶
func FindPlayerByUsername ¶
func (*Player) FormatCreatedAt ¶
func (*Player) FormatLastPlayedAt ¶
func (*Player) FormatUpdatedAt ¶
func (*Player) RefreshIsPlaying ¶
func (p *Player) RefreshIsPlaying()