db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package db contains TimeEntry related CRUD functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store manages the set of APIs for user access.

func NewStore

func NewStore(log *zap.SugaredLogger, db *sqlx.DB) Store

NewStore constructs a data for api access.

func (Store) Create

func (s Store) Create(ctx context.Context, te TimeEntry) error

Create adds a TimeEntry to the database. It returns the created TimeEntry with fields like ID and DateCreated populated.

func (Store) Delete

func (s Store) Delete(ctx context.Context, timeEntryID string) error

Delete removes the TimeEntry identified by a given ID.

func (Store) QueryActivity

func (s Store) QueryActivity(ctx context.Context, userID string) ([]TimeEntry, error)

QueryActivity gets last TimeEntry from the database.

func (Store) QueryByID

func (s Store) QueryByID(ctx context.Context, timeEntryID string) (TimeEntry, error)

QueryByID finds the time_entry identified by a given ID.

func (Store) QueryMostActive

func (s Store) QueryMostActive(ctx context.Context, userID string) ([]TimeEntry, error)

QueryMostActive user in all TimeEntry from the database.

func (Store) QueryProjectTime

func (s Store) QueryProjectTime(ctx context.Context, projectID string) (TimeEntry, error)

QueryProjectTime sync specified project time from the database.

func (Store) QueryRange

func (s Store) QueryRange(ctx context.Context, userID string, pageNumber, rowsPerPage int, start, end time.Time) ([]TimeEntry, error)

QueryRange gets all TimeEntry from the database.

func (Store) QueryRunning

func (s Store) QueryRunning(ctx context.Context, userID string, pageNumber int, rowsPerPage int) ([]TimeEntry, error)

QueryRunning gets all TimeEntry from the database.

func (Store) QueryTaskTime

func (s Store) QueryTaskTime(ctx context.Context, taskID string) (TimeEntry, error)

QueryTaskTime sync the specified task time from the database.

func (Store) Tran

func (s Store) Tran(tx sqlx.ExtContext) Store

Tran return new Store with transaction in it.

func (Store) Update

func (s Store) Update(ctx context.Context, te TimeEntry) error

Update modifies data about a TimeEntry. It will error if the specified ID is invalid or does not reference an existing TimeEntry.

func (Store) UpdateProjectTime

func (s Store) UpdateProjectTime(ctx context.Context, data dbp.Project) error

UpdateProjectTime modifies data about a TimeEntry. It will error if the specified ID is invalid or does not reference an existing TimeEntry.

func (Store) UpdateTaskTime

func (s Store) UpdateTaskTime(ctx context.Context, data db.Task) error

UpdateTaskTime modifies data about a TimeEntry. It will error if the specified ID is invalid or does not reference an existing TimeEntry.

func (Store) WithinTran

func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error

WithinTran runs passed function and do commit/rollback at the end.

type TimeEntry

type TimeEntry struct {
	ID          string         `db:"time_entry_id"`
	Description string         `db:"description"`
	Uid         string         `db:"uid"`
	Wid         string         `db:"wid"`
	Pid         string         `db:"pid"`
	Tid         string         `db:"tid"`
	Billable    bool           `db:"billable"`
	Start       time.Time      `db:"start"`
	Stop        time.Time      `db:"stop"`
	Duration    time.Duration  `db:"duration"`
	CreatedWith string         `db:"created_with"`
	Tags        pq.StringArray `db:"tags"`
	DurOnly     bool           `db:"dur_only"`
	DateCreated time.Time      `db:"date_created"`
	DateUpdated time.Time      `db:"date_updated"`
}

TimeEntry represent the structure we need for moving data between the app and the database.

Jump to

Keyboard shortcuts

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