Documentation
¶
Overview ¶
Package databaser provides SQLite database connection and operations.
Index ¶
- func InTransaction(ctx context.Context, db *DB, f func(tx *sqlx.Tx) error) error
- func SaveManyEventsTx(ctx context.Context, tx *sqlx.Tx, events []*Event) error
- type DB
- func (db *DB) Close() error
- func (db *DB) GetEvents(ctx context.Context, period time.Duration, location *time.Location) ([]Event, error)
- func (db *DB) Init(ctx context.Context) error
- func (db *DB) SaveEvent(ctx context.Context, event Event) error
- func (db *DB) SaveManyEvents(ctx context.Context, events []Event) error
- type Event
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InTransaction ¶
InTransaction executes the given function within a database transaction.
Types ¶
type DB ¶
DB wraps sqlx.DB for database operations.
func (*DB) GetEvents ¶
func (db *DB) GetEvents(ctx context.Context, period time.Duration, location *time.Location) ([]Event, error)
GetEvents retrieves events to the current time minus the given period.
type Event ¶
Event represents a load event with a timestamp and load percentage.
func NewEventFromCSVRecord ¶
NewEventFromCSVRecord creates an Event from a CSV record.