models

package
v0.0.0-...-ad498cf Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyPassword

func VerifyPassword(hashedPassword, password string) error

Types

type Group

type Group struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Name      string    `gorm:"size:1000;not null;" json:"name"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
}

func (*Group) DeleteGroup

func (g *Group) DeleteGroup(db *gorm.DB, gid uint32) (int64, error)

func (*Group) FillFields

func (g *Group) FillFields()

func (*Group) FindAllGroups

func (g *Group) FindAllGroups(db *gorm.DB) (*[]Group, error)

func (*Group) FindGroupById

func (g *Group) FindGroupById(db *gorm.DB, gid uint32) (*Group, error)

func (*Group) SaveGroup

func (g *Group) SaveGroup(db *gorm.DB) (*Group, error)

func (*Group) UpdateGroup

func (g *Group) UpdateGroup(db *gorm.DB, gid uint32) (*Group, error)

func (*Group) Validate

func (g *Group) Validate() error

type IntersectionTestQuestion

type IntersectionTestQuestion struct {
	ID         uint32
	QuestionID uint32 `gorm:"foreignkey:question_id"`
	TestID     uint32 `gorm:"foreignkey:test_id"`
}

type JsonUser

type JsonUser struct {
	ID    uint32
	Name  string
	Email string
	Role  string
}

type Question

type Question struct {
	ID        uint32         `gorm:"primary_key;auto_increment" json:"id"`
	Name      string         `gorm:"size:1000;not null;" json:"name"`
	Answers   pq.StringArray `gorm:"type:text[];not null;" json:"answers"`
	Correct   pq.StringArray `gorm:"type:text[];not null;" json:"correct"`
	CreatedAt time.Time      `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	GroupID   uint32         `gorm:"type:bigserial;not null;" json:"group_id"`
	TestID    pq.Int32Array  `json:"test_id" gorm:"-"`
}

func (*Question) DeleteQuestion

func (q *Question) DeleteQuestion(db *gorm.DB, qid uint32) (int64, error)

func (*Question) FillFields

func (q *Question) FillFields()

func (*Question) FindAllQuestions

func (q *Question) FindAllQuestions(db *gorm.DB) (*[]Question, error)

func (*Question) FindQuestionById

func (q *Question) FindQuestionById(db *gorm.DB, qid uint32) (*Question, error)

func (*Question) SaveQuestion

func (q *Question) SaveQuestion(db *gorm.DB) (*Question, error)

func (*Question) UpdateQuestion

func (q *Question) UpdateQuestion(db *gorm.DB, qid uint32) (*Question, error)

func (*Question) Validate

func (q *Question) Validate() error

type Test

type Test struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Name      string    `gorm:"size:1000;not null" json:"name"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
}

func (*Test) AddQuestionToTest

func (t *Test) AddQuestionToTest(db *gorm.DB, tid uint32, qid uint32) (*IntersectionTestQuestion, error)

func (*Test) DeleteTest

func (t *Test) DeleteTest(db *gorm.DB, tid uint32) (int64, error)

func (*Test) FillFields

func (t *Test) FillFields()

func (*Test) FindAllTests

func (t *Test) FindAllTests(db *gorm.DB) (*[]Test, error)

func (*Test) FindTestById

func (t *Test) FindTestById(db *gorm.DB, tid uint32) (*[]*Question, error)

func (*Test) SaveTest

func (t *Test) SaveTest(db *gorm.DB) (*Test, error)

func (*Test) UpdateTest

func (t *Test) UpdateTest(db *gorm.DB, tid uint32) (*Test, error)

func (*Test) Validate

func (t *Test) Validate() error

type User

type User struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Name      string    `gorm:"size:255;not null;" json:"name"`
	Email     string    `gorm:"size:100;not null;unique" json:"email"`
	Password  string    `gorm:"size:100;not null;" json:"password"`
	Role      string    `gorm:"size:100;not null;" json:"role"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
}

func (*User) DeleteUser

func (u *User) DeleteUser(db *gorm.DB, uid uint32) (int64, error)

func (*User) FillFields

func (u *User) FillFields()

func (*User) FindAllUsers

func (u *User) FindAllUsers(db *gorm.DB) (*[]User, error)

func (*User) FindUserById

func (u *User) FindUserById(db *gorm.DB, uid uint32) (*JsonUser, error)

func (*User) HashPassword

func (u *User) HashPassword() error

func (*User) SaveUser

func (u *User) SaveUser(db *gorm.DB) (*User, error)

func (*User) UpdateUser

func (u *User) UpdateUser(db *gorm.DB, uid uint32) (*User, error)

func (*User) Validate

func (u *User) Validate(action string) error

Jump to

Keyboard shortcuts

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