db

package
v1.2.2-0...-f26ef2a Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo interface {
	LoadDay(d *time.Time) *WorkingDay
	Insert(wd WorkingDay)
	UpdateDay(wd WorkingDay)
	Delete(wd WorkingDay)
	Overtime() int
	ListRange(start *time.Time, end *time.Time) ([]WorkingDay, error)
}

Repo is an interface for storing working days

type SqlRepo

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

SqlRepo represents a DB access layer

func NewRepo

func NewRepo(dbPath string) *SqlRepo

NewRepo creates and initiates a new repo

func (*SqlRepo) Delete

func (r *SqlRepo) Delete(wd WorkingDay)

Delete removes a working day from the database

func (*SqlRepo) Insert

func (r *SqlRepo) Insert(wd WorkingDay)

Insert adds a new working day to the database

func (*SqlRepo) ListRange

func (r *SqlRepo) ListRange(start *time.Time, end *time.Time) ([]WorkingDay, error)

func (*SqlRepo) LoadDay

func (r *SqlRepo) LoadDay(d *time.Time) *WorkingDay

LoadDay finds the matching working time entry for a specific date.

func (*SqlRepo) Overtime

func (r *SqlRepo) Overtime() int

Overtime calculates the overtime in minutes

func (*SqlRepo) UpdateDay

func (r *SqlRepo) UpdateDay(wd WorkingDay)

UpdateDay updates the values of a working day in the database

type WorkingDay

type WorkingDay struct {
	gorm.Model

	Start time.Time
	End   time.Time

	Brk  int `gorm:"column:break_in_m"`
	Note string
}

WorkingDay represents one day of work

func (*WorkingDay) String

func (wd *WorkingDay) String() string

func (*WorkingDay) ToRow

func (wd *WorkingDay) ToRow() table.Row

Jump to

Keyboard shortcuts

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