models

package
v0.0.0-...-a36e7e9 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 3 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               uint     `json:"choice_id"`
	QuestionID       uint     `gorm:"not null"`
	Text             string   `gorm:"not null" json:"text"`
	IsCorrect        bool     `json:"is_correct"`
	LinkedQuestionID uint     `json:"linked_question_id"`
	Question         Question `gorm:"foreignKey:QuestionID;references:ID;constraint:OnDelete:CASCADE;"`
}

type Question

type Question struct {
	ID                uint   `json:"question_id"`
	SurveyID          uint   `gorm:"not null"`
	Text              string `gorm:"not null" json:"text"`
	HasMultipleChoice bool   `gorm:"default:false" json:"has_multiple_choice"`
	MediaUrl          string `json:"media_url"`
	Order             int
	LinkedQuestionID  uint
	Survey            Survey   `gorm:"foreignKey:SurveyID;references:ID;constraint:OnDelete:CASCADE;"`
	Choices           []Choice `gorm:"foreignKey:QuestionID;constraint:OnDelete:CASCADE;" json:"choices"`
}

type Survey

type Survey struct {
	ID                 uint `gorm:"primarykey" json:"survey_id"`
	CreatedAt          time.Time
	UpdatedAt          time.Time
	DeletedAt          gorm.DeletedAt          `gorm:"index"`
	OwnerID            uint                    `gorm:"not null" json:"user_id"`
	Title              string                  `gorm:"not null" json:"title"`
	StartTime          time.Time               `gorm:"not null" json:"start_time"`
	EndTime            time.Time               `gorm:"not null" json:"end_time"`
	IsSequential       bool                    `gorm:"default:false" json:"is_sequential"`
	AllowReturn        bool                    `gorm:"default:false" json:"allow_return"`
	ParticipationLimit int                     `gorm:"default:1" json:"participation_limit"`
	AnswerTimeLimit    int                     `gorm:"not null" json:"answer_time_limit"`
	Owner              models.User             `gorm:"foreignKey:OwnerID;references:ID;constraint:OnDelete:CASCADE;"`
	Questions          []Question              `gorm:"foreignKey:SurveyID;constraint:OnDelete:CASCADE;" json:"questions"`
	UserSurveyRoles    []models.UserSurveyRole `gorm:"foreignKey:SurveyID;constraint:OnDelete:CASCADE;"`
	VoteVisibilities   []models.VoteVisibility `gorm:"foreignKey:SurveyID;constraint:OnDelete:CASCADE;"`
	Options            []SurveyOption          `gorm:"foreignKey:SurveyId;constraint:OnDelete:CASCADE;"`
}

type SurveyOption

type SurveyOption struct {
	ID        uint `gorm:"primarykey" json:"id"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	UserId    uint           `gorm:"not null" json:"user_id"`
	SurveyId  uint           `gorm:"not null" json:"survey_id"`
	Name      string         `gorm:"not null" json:"name"`
	Value     string         `gorm:"not null" json:"value"`
	User      models.User    `gorm:"foreignKey:UserId;references:ID;constraint:OnDelete:CASCADE;" json:"user"`
	Survey    Survey         `gorm:"foreignKey:SurveyId;references:ID;constraint:OnDelete:CASCADE;" json:"survey"`
}

type UserSurveyParticipation

type UserSurveyParticipation struct {
	ID          uint `gorm:"primarykey" json:"id"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   gorm.DeletedAt `gorm:"index"`
	UserId      uint           `gorm:"not null" json:"user_id"`
	SurveyID    uint           `gorm:"not null" json:"survey_id"`
	StartAt     time.Time      `gorm:"not null" json:"start_at"`
	EndAt       *time.Time     `gorm:"default:null" json:"end_at"`
	CommittedAt *time.Time     `gorm:"default:null" json:"committed_at"`
	User        models.User    `gorm:"foreignKey:UserId;references:ID;"`
	Survey      Survey         `gorm:"foreignKey:SurveyID;references:ID;"`
}

type Vote

type Vote struct {
	ID         uint      `gorm:"primarykey" json:"id"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time
	DeletedAt  gorm.DeletedAt `gorm:"index"`
	VoterID    uint           `gorm:"not null" json:"voter_id"`
	QuestionID uint           `gorm:"not null" json:"question_id"`
	Answer     string         `gorm:"not null" json:"answer"`
	IsCorrect  bool           `json:"is_correct"`
	Voter      models.User    `gorm:"foreignKey:VoterID;references:ID;constraint:OnDelete:CASCADE;" json:"voter"`
	Question   Question       `gorm:"foreignKey:QuestionID;references:ID;constraint:OnDelete:CASCADE;" json:"question"`
}

Jump to

Keyboard shortcuts

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