models

package
v0.0.0-...-1c961dd Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	DB *sql.DB
}

func (*Connection) GetAllUsers

func (db *Connection) GetAllUsers() (*UsersDB, error)

func (*Connection) GetUserFriends

func (db *Connection) GetUserFriends(userId string) (*UserFriendsDB, error)

func (*Connection) GetUserGameState

func (db *Connection) GetUserGameState(userId string) (*GameStateDB, error)

func (*Connection) InsertUser

func (db *Connection) InsertUser(userId, name string) error

func (*Connection) InsertUserGameState

func (db *Connection) InsertUserGameState(gsu GameStateUpdate) error

func (*Connection) UpdateUserFriends

func (db *Connection) UpdateUserFriends(userId string, friends []string) error

func (*Connection) UpdateUserGameState

func (db *Connection) UpdateUserGameState(gsu GameStateUpdate) (int, error)

type Friend

type Friend struct {
	ID        string          `db:"id" json:"id"`
	Name      string          `db:"name" json:"name"`
	Highscore utils.NullInt64 `db:"score" json:"highscore"`
}

type GameState

type GameState struct {
	GamesPlayed int `json:"gamesPlayed"`
	Score       int `json:"score"`
}

type GameStateDB

type GameStateDB struct {
	GamesPlayed int `db:"games_played"`
	Score       int `db:"score"`
}

type GameStateUpdate

type GameStateUpdate struct {
	GamesPlayed int
	Score       int
	UserId      string
}

type Spec

type Spec interface {
	//GetAllUsers() error
	InsertUser(userId, name string) error
	InsertUserGameState(gsu GameStateUpdate) error
	GetUserGameState(userId string) (*GameStateDB, error)
	UpdateUserGameState(gsu GameStateUpdate) (int, error)
	UpdateUserFriends(userId string, friends []string) error
	GetUserFriends(userId string) (*UserFriendsDB, error)
	GetAllUsers() (*UsersDB, error)
}

func NewDatabaseConnection

func NewDatabaseConnection() Spec

type User

type User struct {
	UserID string `json:"id" db:"id"`
	Name   string `json:"name" db:"name"`
}

type UserCreatePayload

type UserCreatePayload struct {
	Name string `json:"name" binding:"required"`
}

type UserFriends

type UserFriends struct {
	Friends []Friend `json:"friends"`
}

type UserFriendsDB

type UserFriendsDB struct {
	Friends []Friend
}

type UserFriendsPayload

type UserFriendsPayload struct {
	Friends []string `json:"friends" binding:"required"`
}

type UserIDParam

type UserIDParam struct {
	UserID string `uri:"user_id" binding:"required,uuid"`
}

type Users

type Users struct {
	Users []User `json:"users"`
}

type UsersDB

type UsersDB struct {
	Users []User
}

Jump to

Keyboard shortcuts

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