32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()" json:"id"`
|
|
FirstName string `gorm:"not null" json:"first_name"`
|
|
LastName string `gorm:"not null" json:"last_name"`
|
|
Username string `gorm:"unique;not null" json:"username"`
|
|
Email string `gorm:"unique;not null" json:"email"`
|
|
Password string `gorm:"unique;not null" json:"-"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
|
|
Organizations []Organization `gorm:"many2many:user_organizations;" json:"organizations,omitempty"`
|
|
|
|
CreatedOrganization []Organization `gorm:"foreignKey:CreatedBy" json:"created_organization,omitempty"`
|
|
|
|
CreatedQuiz []Quiz `gorm:"foreignKey:CreatedBy" json:"created_quiz,omitempty"`
|
|
UpdatedQuiz []Quiz `gorm:"foreignKey:UpdatedBy" json:"updated_quiz,omitempty"`
|
|
}
|
|
|
|
func (User) TableName() string {
|
|
return "users"
|
|
}
|