services

package
v0.0.0-...-468ce51 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CollectionName = "employee"

CollectionName is the table in mongoDB

View Source
const DbConnectionString = "mongodb://192.168.99.100:27017"

DbConnectionString should be read from environment

View Source
const DbName = "aicumendb"

DbName is the name of my DB in Mongo

Variables

This section is empty.

Functions

This section is empty.

Types

type EmployeeService

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

EmployeeService provides the implementation of EmployeeServiceIface

func NewEmployeeService

func NewEmployeeService() *EmployeeService

NewEmployeeService is the constructor for EmployeeService Struct

func (*EmployeeService) DeleteEmployee

func (service *EmployeeService) DeleteEmployee(employeeID string) error

DeleteEmployee deletes an employee permenantly from collection

func (*EmployeeService) GetEmployee

func (service *EmployeeService) GetEmployee(employeeID string) (models.Employee, error)

GetEmployee gets the employee details with the given employeeID

func (*EmployeeService) ListAllEmployees

func (service *EmployeeService) ListAllEmployees() ([]models.Employee, error)

ListAllEmployees list down all the employees from the DB

func (*EmployeeService) PatchEmployeeDetails

func (service *EmployeeService) PatchEmployeeDetails(employeeID string, employeeDetails models.Employee) error

PatchEmployeeDetails updates the employee details

func (*EmployeeService) PostEmployee

func (service *EmployeeService) PostEmployee(employee models.Employee) (string, error)

PostEmployee adds an employee to the DB

func (*EmployeeService) SearchEmployee

func (service *EmployeeService) SearchEmployee(query string) ([]models.Employee, error)

SearchEmployee lists down all the employees who match a search query

type EmployeeServiceIface

type EmployeeServiceIface interface {
	PostEmployee(employee models.Employee) (string, error)
	ListAllEmployees() ([]models.Employee, error)
	SearchEmployee(query string) ([]models.Employee, error)
	PatchEmployeeDetails(employeeID string, employeeDetails models.Employee) error
	GetEmployee(employeeID string) (models.Employee, error)
	DeleteEmployee(employeeID string) error
}

EmployeeServiceIface abstracts the methods for EmployeeService Implementation

Jump to

Keyboard shortcuts

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