sqlite

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sqlite stores pads and shifts in a SQLite database. Times are stored as unix timestamps, so we can easily compare them.

Shift statements must be called with shift ids that are confirmed to belong to our pad (e. g. from GetShift). Taker statements must be called with taker ids that are confirmed to belong to the selected shift.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

This section is empty.

Types

type DB

type DB struct {
	SQLDB *sql.DB
	// contains filtered or unexported fields
}

func OpenDB

func OpenDB(dbpath string) (*DB, error)

func (*DB) AddPad

func (db *DB) AddPad(pad shiftpad.Pad) error

func (*DB) AddShift

func (db *DB) AddShift(pad *shiftpad.Pad, shift shiftpad.Shift) error

func (*DB) ApproveTake added in v0.5.0

func (db *DB) ApproveTake(shift *shiftpad.Shift, take shiftpad.Take) error

func (*DB) DeletePad

func (db *DB) DeletePad(pad shiftpad.Pad) error

func (*DB) DeletePads

func (db *DB) DeletePads(cutoff string) error

func (*DB) DeleteShift

func (db *DB) DeleteShift(shift *shiftpad.Shift) error

func (*DB) GetPad

func (db *DB) GetPad(id string) (*shiftpad.Pad, error)

func (*DB) GetShift

func (db *DB) GetShift(pad *shiftpad.Pad, id int) (*shiftpad.Shift, error)

func (*DB) GetShifts

func (db *DB) GetShifts(pad *shiftpad.Pad, from, to int64) ([]shiftpad.Shift, error)

func (*DB) GetShiftsByEvent

func (db *DB) GetShiftsByEvent(pad *shiftpad.Pad, eventUID string) ([]shiftpad.Shift, error)

func (*DB) GetTakerNames added in v0.6.0

func (db *DB) GetTakerNames(pad *shiftpad.Pad) ([]string, error)

func (*DB) GetTakersByShift added in v0.6.0

func (db *DB) GetTakersByShift(shift int) ([]shiftpad.Take, error)

func (*DB) GetTakesByTaker added in v0.6.0

func (db *DB) GetTakesByTaker(pad *shiftpad.Pad, name string) ([]shiftpad.Shift, error)

returned shifts contain only takes with the given taker name

func (*DB) SetPaidOut added in v0.6.0

func (db *DB) SetPaidOut(takes []shiftpad.Take) error

SetPaidOut writes take.PaidOut to the database. Alternatively, we could delete and re-add the takes.

func (*DB) TakeShift

func (db *DB) TakeShift(pad *shiftpad.Pad, shift *shiftpad.Shift, take shiftpad.Take) error

func (*DB) UpdatePad

func (db *DB) UpdatePad(pad *shiftpad.Pad) error

func (*DB) UpdatePadLastUpdated

func (db *DB) UpdatePadLastUpdated(pad *shiftpad.Pad, lastUpdated string) error

func (*DB) UpdateShift

func (db *DB) UpdateShift(pad *shiftpad.Pad, shift *shiftpad.Shift) error

Jump to

Keyboard shortcuts

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