Documentation
¶
Overview ¶
Package sqlite implements myhours.Database on top of SQLite.
Contains also utilities for initializing a new SQLite databases with the required schema.
Index ¶
- func InitiateSQLiteDatabase(dbFile string) (*sql.DB, error)
- type Option
- type SQLite
- func (db *SQLite) ActiveRecord() (*myhours.Record, error)
- func (db *SQLite) Categories() ([]myhours.Category, error)
- func (db *SQLite) ImportRecords(records []myhours.Record) ([]int64, error)
- func (db *SQLite) Record(id int64) (*myhours.Record, error)
- func (db *SQLite) Records(from, before time.Time) ([]myhours.Record, error)
- func (db *SQLite) RecordsInCategory(from, before time.Time, categoryID int64) ([]myhours.Record, error)
- func (db *SQLite) Settings() (*myhours.Settings, error)
- func (db *SQLite) StartRecord(start time.Time, categoryID int64, notes string) (int64, error)
- func (db *SQLite) UpdateRecord(recordID int64, categoryID int64, start, end time.Time, notes string) error
- func (db *SQLite) UpdateSetting(key myhours.Setting, value string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*SQLite)
Option defines option function for SQLite based Database solution.
type SQLite ¶
type SQLite struct {
// contains filtered or unexported fields
}
SQLite implements Database on top of SQLite.
func NewSQLite ¶
NewSQLite return a SQLite database implementation using given *sql.DB handle.
Use for example InitiateSQLiteDatabase to open/initiate an SQLite based *sql.DB handle.
func (*SQLite) ActiveRecord ¶
ActiveRecord finds the first myhours.Record from database that has no end time set yet.
func (*SQLite) Categories ¶
Categories returns all myhours.Category entries.
func (*SQLite) ImportRecords ¶
ImportRecords inserts the given records into the database. All records are validated before insert.
Inserts are done in a transaction, so the result is all or nothing.
Returns the IDs of created records.
func (*SQLite) RecordsInCategory ¶
func (db *SQLite) RecordsInCategory(from, before time.Time, categoryID int64) ([]myhours.Record, error)
RecordsInCategory retrieves records for given timestamps [from, before) that have the given category.
func (*SQLite) StartRecord ¶
StartRecord inserts a new myhours.Record into the database, setting only the start time to indicate the record is started, but not finished.