repository

package
v0.0.0-...-1afdef6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateEmail = errors.New("duplicate email")
	ErrNotFound       = errors.New("resource not found")
)

Functions

This section is empty.

Types

type Storage

type Storage struct {
	Students StudentRepository
}

func NewStudentStore

func NewStudentStore(db *sql.DB) *Storage

type Student

type Student struct {
	ID        int64     `json:"id"`
	FirstName string    `json:"firstName" binding:"required"`
	LastName  string    `json:"lastName" binding:"required"`
	Email     string    `json:"email" binding:"required,email"`
	Age       int       `json:"age" binding:"required,gte=0,lte=150"`
	Sex       string    `json:"sex" binding:"required,oneof=M F Other"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Version   int       `json:"version"`
}

type StudentRepository

type StudentRepository interface {
	Create(context.Context, *Student) error
	GetByID(context.Context, int64) (*Student, error)
	Update(context.Context, *Student) error
}

type StudentStore

type StudentStore struct {
	// contains filtered or unexported fields
}

func (*StudentStore) Create

func (s *StudentStore) Create(ctx context.Context, student *Student) error

func (*StudentStore) Delete

func (s *StudentStore) Delete(ctx context.Context, studentID int64) error

func (*StudentStore) GetByID

func (s *StudentStore) GetByID(ctx context.Context, studentID int64) (*Student, error)

func (*StudentStore) Update

func (s *StudentStore) Update(ctx context.Context, student *Student) error

Jump to

Keyboard shortcuts

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