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 ¶
- Variables
- func Close()
- func DeleteProject(name string) error
- func DeleteRecord(id uuid.UUID) error
- func DeleteUser(name string) error
- func GetActiveProject(u string) *models.Project
- func GetAllProjects() ([]models.Project, error)
- func GetAllRecords() ([]models.Record, error)
- func GetAllRecordsForUser(u string) ([]models.Record, error)
- func GetAllUsers() ([]models.User, error)
- func GetProject(name string) (models.Project, error)
- func GetRecord(id uuid.UUID) (models.Record, error)
- func GetReportRecords(req models.DatabaseReportRequest) ([]models.Record, error)
- func GetTodaysRecords() ([]models.Record, error)
- func GetTodaysRecordsForUser(user string) ([]models.Record, error)
- func GetUser(name string) (models.User, error)
- func InitializeDatabase() error
- func SaveProject(p *models.Project) error
- func SaveRecord(r *models.Record) error
- func SaveUser(u *models.User) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoResults is returned when a db record does not exist in db. ErrNoResults = errors.New("no results found") )
Functions ¶
func DeleteProject ¶
DeleteProject deletes a project from the db.
func GetActiveProject ¶
GetActiveProject retrieves the project for which time is aatively being recorded.
func GetAllProjects ¶
GetAllProjects retrieves all projects from db.
func GetAllRecords ¶
GetAllRecords returns all records from db.
func GetAllRecordsForUser ¶
GetAllRecordsForUser returns all records created by user from db.
func GetAllUsers ¶
GetAllUsers retrieves all users from db.
func GetProject ¶
GetProject retrives a project from db.
func GetReportRecords ¶
func GetReportRecords(req models.DatabaseReportRequest) ([]models.Record, error)
GetReportRecords returns record matching the request.
func GetTodaysRecords ¶
GetTodaysRecords returns records created on this day.
func GetTodaysRecordsForUser ¶
GetTodaysRecordsForUser return records created on this day by specified user.
func InitializeDatabase ¶
func InitializeDatabase() error
InitializeDatabase opens (creates if it does not exist) the db and creates any non-exitent tables.
Types ¶
This section is empty.