timelogmapper

package
v0.0.0-...-290a973 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package timelogmapper provides functionality to read and persist timelogs.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLoadFromDB occurs if something went wrong on loading.
	ErrLoadFromDB = errors.New("failed to load timelog from database")

	// ErrNoData occurs if given model is nil.
	ErrNoData = errors.New("timelog is nil")

	// ErrSaveToDB occurs if something went wrong on saving.
	ErrSaveToDB = errors.New("failed to save timelog to database")

	// ErrDeleteFromDB occurs if something went wrong on deleting.
	ErrDeleteFromDB = errors.New("failed to delete timelog from database")

	// ErrNotFound occurs if record doesn't exist in database.
	ErrNotFound = errors.New("timelog was not found")
)

Functions

func StoreToModel

func StoreToModel(s *timelogstore.Timelog) *timelogmodel.Timelog

StoreToModel returns a model based on the given store object. It maps all properties from store to model.

Types

type Mapper

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

Mapper provides methods to load and persist timelog models.

func New

func New(db *sqlx.DB) *Mapper

New returns a new mapper.

func (*Mapper) Delete

func (m *Mapper) Delete(ctx context.Context, id uuid.UUID) error

Delete removes a model from database by ID.

func (*Mapper) Load

func (m *Mapper) Load(ctx context.Context, id uuid.UUID) (*timelogmodel.Timelog, error)

Load returns a timelog model loaded from database by ID.

func (*Mapper) LoadByDateRange

func (m *Mapper) LoadByDateRange(ctx context.Context, start, stop string) (timelogmodel.Timelogs, error)

func (*Mapper) Save

Save persists (create or update) the model and returns the changed data (id, createdAt or modifiedAt).

Jump to

Keyboard shortcuts

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