models

package
v0.0.0-...-103267c Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	ID        uint64    `gorm:"primaryKey;autoIncrement" json:"id"`
	Choice    string    `gorm:"type:varchar(191);not null" json:"choice"`
	Poll      Poll      `gorm:"foreignKey:PollID" json:"poll"`
	PollID    uint64    `json:"poll_id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*Choice) BeforeCreate

func (choice *Choice) BeforeCreate(tx *gorm.DB) (err error)

func (*Choice) BeforeUpdate

func (choice *Choice) BeforeUpdate(tx *gorm.DB) (err error)

type Division

type Division struct {
	ID        uint64    `gorm:"primaryKey;autoIncrement" json:"id"`
	Name      string    `gorm:"type:varchar(191);not null" json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Users     []User    `gorm:"foreignKey:DivisionID" json:"users"`
}

func (*Division) BeforeCreate

func (division *Division) BeforeCreate(tx *gorm.DB) (err error)

func (*Division) BeforeUpdate

func (division *Division) BeforeUpdate(tx *gorm.DB) (err error)

type Poll

type Poll struct {
	ID          uint64    `gorm:"primaryKey;autoIncrement" json:"id"`
	Title       string    `gorm:"type:varchar(191);not null" json:"name"`
	Description string    `gorm:"type:varchar(191);not null" json:"description"`
	Deadline    time.Time `json:"deadline"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	DeletedAt   time.Time `gorm:"index" json:"deleted_at"`
	Creator     User      `gorm:"foreignKey:CreatedBy" json:"creator"`
	CreatedBy   uint64    `json:"created_by"`
}

func (*Poll) BeforeCreate

func (poll *Poll) BeforeCreate(tx *gorm.DB) (err error)

func (*Poll) BeforeDelete

func (poll *Poll) BeforeDelete(tx *gorm.DB) (err error)

func (*Poll) BeforeUpdate

func (poll *Poll) BeforeUpdate(tx *gorm.DB) (err error)

type RoleLevels

type RoleLevels string
const (
	USER  RoleLevels = "USER"
	ADMIN RoleLevels = "ADMIN"
)

type User

type User struct {
	ID         uint64     `gorm:"primaryKey;autoIncrement" json:"id"`
	Username   string     `gorm:"type:varchar(191);not null" json:"username"`
	Password   string     `gorm:"type:varchar(191);not null" json:"password"`
	Role       RoleLevels `gorm:"type:role_level" json:"role"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	Division   Division   `gorm:"foreignKey:DivisionID" json:"division"`
	DivisionID *uint64    `json:"division_id"`
}

func (*User) BeforeCreate

func (user *User) BeforeCreate(tx *gorm.DB) (err error)

func (*User) BeforeUpdate

func (user *User) BeforeUpdate(tx *gorm.DB) (err error)

type Vote

type Vote struct {
	ID         uint64    `gorm:"primaryKey;autoIncrement" json:"id"`
	Choice     Choice    `gorm:"foreignKey:ChoiceID" json:"choice"`
	ChoiceID   uint64    `json:"choice_id"`
	User       User      `gorm:"foreignKey:UserID" json:"user"`
	UserID     uint64    `json:"user_id"`
	Poll       Poll      `gorm:"foreignKey:PollID" json:"poll"`
	PollID     uint64    `json:"poll_id"`
	Division   Division  `gorm:"foreignKey:DivisionID" json:"division"`
	DivisionID uint64    `json:"division_id"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

func (*Vote) BeforeCreate

func (vote *Vote) BeforeCreate(tx *gorm.DB) (err error)

func (*Vote) BeforeUpdate

func (vote *Vote) BeforeUpdate(tx *gorm.DB) (err error)

Jump to

Keyboard shortcuts

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