Versions in this module Expand all Collapse all v1 v1.0.0 Jan 3, 2023 Changes in this version + const ScopeActivation + const ScopeAuthentication + const ScopePasswordReset + var AnonymousUser = &User + var ErrDuplicateEmail = errors.New("duplicate email") + var ErrEditConflict = errors.New("edit conflict") + var ErrInvalidRuntimeFormat = errors.New("invalid runtime format") + var ErrRecordNotFound = errors.New("record not found") + func ValidateEmail(v *validator.Validator, email string) + func ValidateFilters(v *validator.Validator, f Filters) + func ValidateMovie(v *validator.Validator, movie *Movie) + func ValidatePasswordPlaintext(v *validator.Validator, password string) + func ValidateTokenPlaintext(v *validator.Validator, tokenPlaintext string) + func ValidateUser(v *validator.Validator, user *User) + type Filters struct + Page int + PageSize int + Sort string + SortSafelist []string + type Metadata struct + CurrentPage int + FirstPage int + LastPage int + PageSize int + TotalRecords int + type MockMovieModel struct + type Models struct + Movies MovieModel + Permissions PermissionModel + Tokens TokenModel + Users UserModel + func NewModels(db *sql.DB) Models + type Movie struct + CreatedAt time.Time + Genres []string + ID int64 + Runtime Runtime + Title string + Version int32 + Year int32 + type MovieModel struct + DB *sql.DB + func (m MovieModel) Delete(id int64) error + func (m MovieModel) Get(id int64) (*Movie, error) + func (m MovieModel) GetAll(title string, genres []string, filters Filters) ([]*Movie, Metadata, error) + func (m MovieModel) Insert(movie *Movie) error + func (m MovieModel) Update(movie *Movie) error + type PermissionModel struct + DB *sql.DB + func (m PermissionModel) AddForUser(userID int64, codes ...string) error + func (m PermissionModel) GetAllForUser(userID int64) (Permissions, error) + type Permissions []string + func (p Permissions) Include(code string) bool + type Runtime int32 + func (r *Runtime) UnmarshalJSON(jsonValue []byte) error + func (r Runtime) MarshalJSON() ([]byte, error) + type Token struct + Expiry time.Time + Hash []byte + Plaintext string + Scope string + UserID int64 + type TokenModel struct + DB *sql.DB + func (m TokenModel) DeleteAllForUser(scope string, userID int64) error + func (m TokenModel) Insert(token *Token) error + func (m TokenModel) New(userID int64, ttl time.Duration, scope string) (*Token, error) + type User struct + Activated bool + CreatedAt time.Time + Email string + ID int64 + Name string + Password password + Version int + func (u *User) IsAnonymous() bool + type UserModel struct + DB *sql.DB + func (m UserModel) Get(id int64) (*User, error) + func (m UserModel) GetByEmail(email string) (*User, error) + func (m UserModel) GetForToken(tokenScope, tokenPlaintext string) (*User, error) + func (m UserModel) Insert(user *User) error + func (m UserModel) Update(user *User) error