database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package database manages persistent storage for timetraced using bbolt. It initializes and closes the database, and provides functions to create, retrieve, update, and delete projects, users, and records. The package also includes queries for common application needs such as active projects, daily records, and report generation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoResults is returned when a db record does not exist in db.
	ErrNoResults = errors.New("no results found")
)

Functions

func Close

func Close()

Close closes the db file.

func DeleteProject

func DeleteProject(name string) error

DeleteProject deletes a project from the db.

func DeleteRecord

func DeleteRecord(id uuid.UUID) error

DeleteRecord deletes a record from db.

func DeleteUser

func DeleteUser(name string) error

DeleteUser deletes a user from db.

func GetActiveProject

func GetActiveProject(u string) *models.Project

GetActiveProject retrieves the project for which time is aatively being recorded.

func GetAllProjects

func GetAllProjects() ([]models.Project, error)

GetAllProjects retrieves all projects from db.

func GetAllRecords

func GetAllRecords() ([]models.Record, error)

GetAllRecords returns all records from db.

func GetAllRecordsForUser

func GetAllRecordsForUser(u string) ([]models.Record, error)

GetAllRecordsForUser returns all records created by user from db.

func GetAllUsers

func GetAllUsers() ([]models.User, error)

GetAllUsers retrieves all users from db.

func GetProject

func GetProject(name string) (models.Project, error)

GetProject retrives a project from db.

func GetRecord

func GetRecord(id uuid.UUID) (models.Record, error)

GetRecord retrives a record form db.

func GetReportRecords

func GetReportRecords(req models.DatabaseReportRequest) ([]models.Record, error)

GetReportRecords returns record matching the request.

func GetTodaysRecords

func GetTodaysRecords() ([]models.Record, error)

GetTodaysRecords returns records created on this day.

func GetTodaysRecordsForUser

func GetTodaysRecordsForUser(user string) ([]models.Record, error)

GetTodaysRecordsForUser return records created on this day by specified user.

func GetUser

func GetUser(name string) (models.User, error)

GetUser retrieves the named user from db.

func InitializeDatabase

func InitializeDatabase() error

InitializeDatabase opens (creates if it does not exist) the db and creates any non-exitent tables.

func SaveProject

func SaveProject(p *models.Project) error

SaveProject saves a project to db.

func SaveRecord

func SaveRecord(r *models.Record) error

SaveRecord saves a record to the db.

func SaveUser

func SaveUser(u *models.User) error

SaveUser saves/updates user in db.

Types

This section is empty.

Jump to

Keyboard shortcuts

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