database

package
v0.0.0-...-f610a31 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitData

func InitData(db *gorm.DB) (err error)

Types

type EmployeeDBModel

type EmployeeDBModel struct {
	ID   int    `gorm:"column:id;primaryKey"`
	Name string `gorm:"column:name"`
	City string `gorm:"column:city"`
}

type Repository

type Repository interface {
	GetAllEmployees(ctx context.Context) ([]EmployeeDBModel, error)
	AddEmployee(ctx context.Context, newEmployee *EmployeeDBModel) error
	GetEmployee(ctx context.Context, employeeID int64) (*EmployeeDBModel, error)
	DeleteEmployee(ctx context.Context, employeeID int64) error
}

func NewSQLRepository

func NewSQLRepository(db *gorm.DB) Repository

type SQLRepository

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

func (SQLRepository) AddEmployee

func (r SQLRepository) AddEmployee(ctx context.Context, newEmployee *EmployeeDBModel) (err error)

func (SQLRepository) DeleteEmployee

func (r SQLRepository) DeleteEmployee(ctx context.Context, employeeID int64) (err error)

func (SQLRepository) GetAllEmployees

func (r SQLRepository) GetAllEmployees(ctx context.Context) (people []EmployeeDBModel, err error)

func (SQLRepository) GetEmployee

func (r SQLRepository) GetEmployee(ctx context.Context, employeeID int64) (*EmployeeDBModel, error)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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