Documentation ¶
Overview ¶
Package db contains TimeEntry related CRUD functionality.
Index ¶
- type Store
- func (s Store) Create(ctx context.Context, te TimeEntry) error
- func (s Store) Delete(ctx context.Context, timeEntryID string) error
- func (s Store) QueryActivity(ctx context.Context, userID string) ([]TimeEntry, error)
- func (s Store) QueryByID(ctx context.Context, timeEntryID string) (TimeEntry, error)
- func (s Store) QueryMostActive(ctx context.Context, userID string) ([]TimeEntry, error)
- func (s Store) QueryProjectTime(ctx context.Context, projectID string) (TimeEntry, error)
- func (s Store) QueryRange(ctx context.Context, userID string, pageNumber, rowsPerPage int, ...) ([]TimeEntry, error)
- func (s Store) QueryRunning(ctx context.Context, userID string, pageNumber int, rowsPerPage int) ([]TimeEntry, error)
- func (s Store) QueryTaskTime(ctx context.Context, taskID string) (TimeEntry, error)
- func (s Store) Tran(tx sqlx.ExtContext) Store
- func (s Store) Update(ctx context.Context, te TimeEntry) error
- func (s Store) UpdateProjectTime(ctx context.Context, data dbp.Project) error
- func (s Store) UpdateTaskTime(ctx context.Context, data db.Task) error
- func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error
- type TimeEntry
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 ¶
Create adds a TimeEntry to the database. It returns the created TimeEntry with fields like ID and DateCreated populated.
func (Store) QueryActivity ¶
QueryActivity gets last TimeEntry from the database.
func (Store) QueryMostActive ¶
QueryMostActive user in all TimeEntry from the database.
func (Store) QueryProjectTime ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.