data

package
v0.0.0-...-bee4d3c Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MongoDbEmployeeToEmployee

func MongoDbEmployeeToEmployee(e *MongoDbEmployee) (*domain.Employee, error)

func MongoDbEmployeesToEmployees

func MongoDbEmployeesToEmployees(mongoDbEmployees []MongoDbEmployee) ([]domain.Employee, error)

Types

type DatabaseError

type DatabaseError struct {
	Operation string
	Err       error
}

func (*DatabaseError) Error

func (e *DatabaseError) Error() string

type EmployeesMongoDBRepository

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

func NewEmployeesMongoDBRepository

func NewEmployeesMongoDBRepository(ctx context.Context,
	mongoUri string, mongoDb string) (*EmployeesMongoDBRepository, error)

func (*EmployeesMongoDBRepository) Add

func (*EmployeesMongoDBRepository) Close

func (r *EmployeesMongoDBRepository) Close() error

func (*EmployeesMongoDBRepository) GetAll

func (*EmployeesMongoDBRepository) GetById

func (*EmployeesMongoDBRepository) ModifyById

func (r *EmployeesMongoDBRepository) ModifyById(ctx context.Context, id string, employee domain.Employee) (*domain.Employee, error)

func (*EmployeesMongoDBRepository) RemoveById

type EmployeesRepository

type EmployeesRepository interface {
	GetAll(ctx context.Context) ([]domain.Employee, error)
	Add(ctx context.Context, employee domain.Employee) (*domain.Employee, error)
	GetById(ctx context.Context, id string) (*domain.Employee, error)
	ModifyById(ctx context.Context, id string, employee domain.Employee) (*domain.Employee, error)
	RemoveById(ctx context.Context, id string) (*domain.Employee, error)
	Close() error
}

type MongoDbEmployee

type MongoDbEmployee struct {
	ID     primitive.ObjectID   `json:"id" bson:"_id,omitempty"`
	Name   string               `json:"name"`
	Salary primitive.Decimal128 `json:"salary"`
	Age    int                  `json:"age"`
}

func EmployeeToMongoDbEmployee

func EmployeeToMongoDbEmployee(e *domain.Employee) (*MongoDbEmployee, error)

type NotFoundError

type NotFoundError struct {
	ID string
}

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Jump to

Keyboard shortcuts

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