repository

package
v0.0.0-...-37076da Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGetStudents

NewGetStudents will return a student.GetStudentsRepository implementation

func NewUpdateStudent

func NewUpdateStudent(db database.Database) student.UpdateStudentRepository

NewUpdateStudent will return a student.UpdateStudentRepository implementation

Types

type StudentModel

type StudentModel struct {
	ID        string    `gorm:"primary_key;column:usr_id;type:uuid;default:uuid_generate_v4();index:idx_usr_id"`
	Email     string    `gorm:"column:usr_email;unique;type:varchar(255);"`
	Password  string    `gorm:"column:usr_password;type:varchar(255)"`
	Type      string    `gorm:"column:usr_scope;type:varchar(64);default:student"`
	CreatedAt time.Time `gorm:"column:usr_created_at;type:timestamp with time zone;default:now()"`
	UpdatedAt time.Time `gorm:"column:usr_updated_at;type:timestamp with time zone;default:now()"`
}

StudentModel represents how a student is stored in the database.

func (*StudentModel) AsDomain

func (s *StudentModel) AsDomain() student.Student

func (*StudentModel) BeforeCreate

func (s *StudentModel) BeforeCreate(*gorm.DB) error

BeforeCreate is a hook to set the created_at, updated_at fields and generate uuid random.

Read more about GORM hooks:

https://gorm.io/docs/hooks.html#Creating-an-object

func (*StudentModel) BeforeUpdate

func (s *StudentModel) BeforeUpdate(tx *gorm.DB) error

BeforeUpdate is a hook to set the updated_at field.

Read more about GORM hooks:

https://gorm.io/docs/hooks.html#Updating-an-object

func (StudentModel) TableName

func (StudentModel) TableName() string

TableName overrides the table name used by StudentModel to `users`

Read more about GORM conventions:

https://gorm.io/docs/conventions.html#TableName

Jump to

Keyboard shortcuts

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