Documentation
¶
Index ¶
- Constants
- Variables
- type Filters
- type Metadata
- type Models
- type Movie
- type MovieModel
- type Permission
- type PermissionModel
- type Runtime
- type Token
- type TokenModel
- type User
- type UserModel
- func (m *UserModel) Delete(id int64) error
- func (m *UserModel) GetAll() ([]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
Constants ¶
View Source
const ( ScopeActivation = "activation" ScopeAuthentication = "authentication" )
Variables ¶
View Source
var AnonymousUser = &User{}
View Source
var ErrInvalidRuntimeFormat = errors.New("invalid runtime format")
View Source
var (
ErrRecordNotFound = errors.New("record not found")
)
Functions ¶
This section is empty.
Types ¶
type Models ¶
type Models struct { Movies MovieModel Users UserModel Tokens TokenModel Permissions PermissionModel }
type Movie ¶
type Movie struct { gorm.Model Title string `json:"title" gorm:"index:,type:gin,expression:to_tsvector('english'\\,title)"` Year int32 `json:"year"` Runtime Runtime `json:"runtime" gorm:"type:int"` Genres pq.StringArray `json:"genres" gorm:"type:text[];index:,type:gin"` Version int32 `json:"version" gorm:"default:1"` }
type MovieModel ¶
func (MovieModel) Delete ¶
func (m MovieModel) Delete(id int64) error
Add a placeholder method for deleting a specific record from the movies table.
func (MovieModel) Get ¶
func (m MovieModel) Get(id int64) (*Movie, error)
Add a placeholder method for fetching a specific record from the movies table.
func (MovieModel) Insert ¶
func (m MovieModel) Insert(movie *Movie) error
Add a placeholder method for inserting a new record in the movies table.
func (MovieModel) Update ¶
func (m MovieModel) Update(movie *Movie) error
Add a placeholder method for updating a specific record in the movies table.
type Permission ¶
type Permission struct { ID uuid.UUID `json:"id" gorm:"default:gen_random_uuid()"` Code pq.StringArray `json:"code" gorm:"type:text[]"` }
func (Permission) Include ¶
func (p Permission) Include(code string) bool
type PermissionModel ¶
func (*PermissionModel) AddForUser ¶
func (m *PermissionModel) AddForUser(userID uint, codes ...string) error
func (*PermissionModel) GetAllForUser ¶
func (m *PermissionModel) GetAllForUser(userID uint) (*Permission, error)
type Runtime ¶
type Runtime int32
func (Runtime) GormDataType ¶
func (Runtime) MarshalJSON ¶
func (*Runtime) UnmarshalJSON ¶
type Token ¶
type TokenModel ¶
func (*TokenModel) DeleteAllForUser ¶
func (m *TokenModel) DeleteAllForUser(scope string, userID uint) error
func (*TokenModel) Insert ¶
func (m *TokenModel) Insert(token *Token) error
type User ¶
type User struct { gorm.Model UUID uuid.UUID `json:"uuid" gorm:"type:uuid"` Name string `json:"name" validate:"required"` Email string `json:"email" gorm:"unique" validate:"required,email"` Password string `json:"-" validate:"required,min=8,max=72"` Activated bool `json:"activated"` Permissions []Permission `json:"permissions" gorm:"many2many:users_permissions"` }
func (*User) CheckPassword ¶
func (*User) IsAnonymous ¶
type UserModel ¶
func (*UserModel) GetForToken ¶
Click to show internal directories.
Click to hide internal directories.