models

package
v0.0.0-...-9d3b622 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 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 Permission

type Permission struct {
	ID     uint
	Action string `gorm:"unique;not null"`
}

type Role

type Role struct {
	gorm.Model
	Name        string       `gorm:"unique;not null"`
	Permissions []Permission `gorm:"many2many:role_permissions;constraint:OnDelete:CASCADE"`
}

type User

type User struct {
	gorm.Model
	RoleID        uint   `gorm:"not null"`
	NationalID    string `gorm:"unique;not null"`
	Email         string `gorm:"unique;not null"`
	PasswordHash  string `gorm:"not null"`
	FirstName     string
	LastName      string
	DateOfBirth   time.Time
	City          string
	WalletBalance float64 `gorm:"default:0"`
	GlobalRole    Role    `gorm:"foreignKey:RoleID;references:ID;constraint:OnDelete:CASCADE;"`
}

type UserSurveyRole

type UserSurveyRole struct {
	ID        uint
	UserID    uint `gorm:"not null"`
	SurveyID  uint `gorm:"not null"`
	RoleID    uint `gorm:"not null"`
	TimeLimit int
	User      User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE;"`
	Role      Role `gorm:"foreignKey:RoleID;constraint:OnDelete:CASCADE;"`
}

type VoteVisibility

type VoteVisibility struct {
	ID           uint
	SurveyID     uint `gorm:"not null"`
	ViewerID     uint `gorm:"not null"` // User allowed to view votes
	RespondentID uint `gorm:"not null"` // User whose votes can be viewed
	Viewer       User `gorm:"foreignKey:ViewerID;constraint:OnDelete:CASCADE;"`
	Respondent   User `gorm:"foreignKey:RespondentID;constraint:OnDelete:CASCADE;"`
}

Jump to

Keyboard shortcuts

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