Documentation ¶
Index ¶
- Variables
- type EmployeeService
- func (es *EmployeeService) AutoMigrate() error
- func (es *EmployeeService) ByCity(city string) *[]models.Employee
- func (es *EmployeeService) ByID(id uint) (*models.Employee, error)
- func (es *EmployeeService) ByName(name string) (*models.Employee, error)
- func (es *EmployeeService) Close() error
- func (es *EmployeeService) Create(employee *models.Employee) error
- func (es *EmployeeService) Delete(id uint) error
- func (es *EmployeeService) DestructiveReset() error
- func (es *EmployeeService) GetAll() *[]models.Employee
- func (es *EmployeeService) Update(employee *models.Employee) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned when a resource cannot be found ErrNotFound = errors.New("models: resource not found") // ErrInvalidID is returned when an invalid ID is provided // to a method like Delete. ErrInvalidID = errors.New("models: ID provided was invalid") )
Functions ¶
This section is empty.
Types ¶
type EmployeeService ¶
type EmployeeService struct {
// contains filtered or unexported fields
}
EmployeeService struct
func NewEmployeeService ¶
func NewEmployeeService(connectionInfo string) (*EmployeeService, error)
NewEmployeeService func
func (*EmployeeService) AutoMigrate ¶
func (es *EmployeeService) AutoMigrate() error
AutoMigrate will attempt to Automigrate the users table
func (*EmployeeService) ByCity ¶
func (es *EmployeeService) ByCity(city string) *[]models.Employee
ByCity will look up a employee by name provided 1 - employee, nil 2 - nil, ErrNoFound 3 - nil, otherError
func (*EmployeeService) ByID ¶
func (es *EmployeeService) ByID(id uint) (*models.Employee, error)
ByID will look up a employee by id provided 1 - employee, nil 2 - nil, ErrNoFound 3 - nil, otherError
func (*EmployeeService) ByName ¶
func (es *EmployeeService) ByName(name string) (*models.Employee, error)
ByName will look up a employee by name provided 1 - employee, nil 2 - nil, ErrNoFound 3 - nil, otherError
func (*EmployeeService) Close ¶
func (es *EmployeeService) Close() error
Close the UserService database connection
func (*EmployeeService) Create ¶
func (es *EmployeeService) Create(employee *models.Employee) error
Create will add employee into the database
func (*EmployeeService) Delete ¶
func (es *EmployeeService) Delete(id uint) error
Delete will delete employee with provided ID
func (*EmployeeService) DestructiveReset ¶
func (es *EmployeeService) DestructiveReset() error
DestructiveReset drops table and rebuilds it
func (*EmployeeService) GetAll ¶
func (es *EmployeeService) GetAll() *[]models.Employee
GetAll will look up all employees
Click to show internal directories.
Click to hide internal directories.