Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseModel ¶
type BaseModel struct { ID string `gorm:"primaryKey" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` }
BaseModel a basic Go struct which includes the following fields: ID (GUID), CreatedAt, UpdatedAt, DeletedAt
type Game ¶
type Game struct { BaseModel Rows int `json:"rows"` Cols int `json:"cols"` Mines int `json:"mines"` Status string `json:"status"` GameState JSONB `json:"gameState" gorm:"type:jsonb"` StartedAt *time.Time `json:"startedAt,omitempty"` FinishedAt *time.Time `json:"finishedAt,omitempty"` CreatedByID string `json:"-"` // who created this game - id needed by GORM CreatedBy *User `json:"createdBy"` // who created this game }
Game contains the structure of the game
func (*Game) GetGameState ¶
func (*Game) UpdateGameState ¶
type User ¶
type User struct { BaseModel Email string `json:"email" gorm:"uniqueIndex"` Username string `json:"username" gorm:"uniqueIndex"` Password string `json:"password"` Fullname string `json:"fullname"` APIKeys []UserAPIKey `json:"apiKeys"` Admin bool `json:"-" gorm:"default:false"` // FUTURE: proper RBAC, roles, permissions, etc. CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
func (*User) BeforeCreate ¶
BeforeCreate hook that runs before entity create
type UserAPIKey ¶
type UserAPIKey struct { ID uint `json:"-" gorm:"primarykey"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` APIKey string `gorm:"unique" json:"apiKey"` UserID string `json:"-"` User User `json:"-"` }
func (*UserAPIKey) BeforeCreate ¶
func (uak *UserAPIKey) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate hook to run before entity create
Click to show internal directories.
Click to hide internal directories.