Documentation ¶
Index ¶
- Variables
- type FranchiseModel
- type GameModel
- func (m *GameModel) AllForUser(userID string) ([]*models.Game, error)
- func (m *GameModel) ChangeGameProgress(userID, gameID string, progress *models.GameProgress) error
- func (m *GameModel) ChangeGameStatus(userID, gameID string, status models.Status) error
- func (m *GameModel) DeleteGame(userID, gameID string) error
- func (m *GameModel) Get(id string) (*models.Game, error)
- func (m *GameModel) Insert(game *models.Game) (*models.Game, error)
- type UserModel
- func (m *UserModel) AssociateTokenWithUser(userID, token string) error
- func (m *UserModel) Authenticate(email, password string) (*models.User, error)
- func (m *UserModel) GetUserByToken(token string) (*models.User, error)
- func (m *UserModel) Insert(user *models.User) (*models.User, error)
- func (m *UserModel) InvalidateToken(userID, token string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNameAlreadyExists is the error that is returned, when a game with that name already exists in the database ErrNameAlreadyExists = errors.New("model with that name already exists in the database") // ErrNoRecord is returned when a game with that criteria does not exist in the database ErrNoRecord = errors.New("such model does not exist in the database") )
var ( // ErrEmailAlreadyExists is returned when a user with the same email already exists in the database ErrEmailAlreadyExists = errors.New("user with the same email already exists") // ErrUsernameAlreadyExists is returned when a user with the same username already exists in the database ErrUsernameAlreadyExists = errors.New("user with the same username already exists") // ErrWrongPassword is returned when the given password does not match the user password ErrWrongPassword = errors.New("the given password does not match the user password") )
Functions ¶
This section is empty.
Types ¶
type FranchiseModel ¶
type FranchiseModel struct {
// contains filtered or unexported fields
}
func NewFranchiseModel ¶
func NewFranchiseModel(db *sql.DB) *FranchiseModel
type GameModel ¶
type GameModel struct {
// contains filtered or unexported fields
}
GameModel wraps an sql.DB connection pool.
func NewGameModel ¶
func (*GameModel) AllForUser ¶
AllForUser fetches all games for the given user from the database and returns them, or an error if such occurred.
func (*GameModel) ChangeGameProgress ¶
func (m *GameModel) ChangeGameProgress(userID, gameID string, progress *models.GameProgress) error
func (*GameModel) ChangeGameStatus ¶
func (*GameModel) DeleteGame ¶
type UserModel ¶
type UserModel struct {
// contains filtered or unexported fields
}
UserModel wraps a DB connection pool.
func NewUserModel ¶
func (*UserModel) AssociateTokenWithUser ¶
AssociateTokenWithUser associated the given token with the given userID
func (*UserModel) Authenticate ¶
Authenticate authenticates a use with these credentials and returns the user or an error if such occurred.
func (*UserModel) GetUserByToken ¶
GetUserByToken returns the user, associated with the token passed to the method
func (*UserModel) Insert ¶
Insert inserts a new user with the given parameters into the database and return the created user ot an error if such occurred.
func (*UserModel) InvalidateToken ¶
InvalidateToken deleted the token from the database, making it invalid