timelogstore

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: 8 Imported by: 0

Documentation

Overview

Package timelogstore contains the CRUD operations for the timelogs on the database.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIDMissing will be thrown if an ID is expected but not set.
	ErrIDMissing = errors.New("id is mandatory for this operation")

	// ErrCreatingID will be thrown if creating an ID failed.
	ErrCreatingID = errors.New("id creation failed")

	// ErrIDIsSet will be thrown if no ID is expected but already set.
	ErrIDIsSet = errors.New("id should be not set for this operation, use update instead")

	// ErrDataMissing will be thrown if mandatory data is not set.
	ErrDataMissing = errors.New("no data or mandatory data missing")
)

Functions

This section is empty.

Types

type Timelog

type Timelog struct {
	ID         uuid.UUID  `db:"id"`
	Start      time.Time  `db:"start"`
	Stop       *time.Time `db:"stop"`
	Reason     string     `db:"reason"`
	Location   string     `db:"location"`
	CreatedAt  time.Time  `db:"created_at"`
	ModifiedAt time.Time  `db:"modified_at"`
}

Timelog represents the timelog in the database.

func (*Timelog) Create

func (t *Timelog) Create(ctx context.Context, db *sqlx.DB) error

Create creates current object in the database.

func (*Timelog) Delete

func (t *Timelog) Delete(ctx context.Context, db *sqlx.DB) error

Delete removes the current object from database by its ID.

func (*Timelog) IsValid

func (t *Timelog) IsValid() bool

IsValid returns true if all mandatory fields are set.

func (*Timelog) Read

func (t *Timelog) Read(ctx context.Context, db *sqlx.DB) error

Read sets the timelog from database by given ID.

func (*Timelog) Update

func (t *Timelog) Update(ctx context.Context, db *sqlx.DB) error

Update changes the current object on the database by ID.

type Timelogs

type Timelogs []*Timelog

func (*Timelogs) Load

func (t *Timelogs) Load(ctx context.Context, db *sqlx.DB, where string, args ...any) error

Jump to

Keyboard shortcuts

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