db

package
v0.0.0-...-6b4eda8 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlreadyExists

func IsAlreadyExists(err error) bool

func IsNotFound

func IsNotFound(err error) bool

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type HRTHistory

type HRTHistory struct {
	DosageAt time.Time
	HRTType  string
}

type Notified

type Notified struct {
	DosageAt   time.Time
	NotifiedAt sql.NullTime
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) DeleteLastDose

func (q *Queries) DeleteLastDose(ctx context.Context, hrtType string) error

func (*Queries) DosageHistory

func (q *Queries) DosageHistory(ctx context.Context, hrtType string) ([]HRTHistory, error)

func (*Queries) LastDose

func (q *Queries) LastDose(ctx context.Context, hrtType string) (HRTHistory, error)

func (*Queries) MarkNotified

func (q *Queries) MarkNotified(ctx context.Context, dosageAt time.Time) error

func (*Queries) RecordDosage

func (q *Queries) RecordDosage(ctx context.Context, hrtType string) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type SQLiteDB

type SQLiteDB struct {
	*Queries
	// contains filtered or unexported fields
}

SQLiteDB provides methods for interacting with the database. For now, it just wraps around sqlc's Queries because I'm lazy.

func Open

func Open(path string) (*SQLiteDB, error)

Open creates a new database at the given path.

func (*SQLiteDB) Close

func (db *SQLiteDB) Close() error

Close closes the database.

func (*SQLiteDB) Tx

func (db *SQLiteDB) Tx(f func(*Queries) error) error

Tx scopes f to a transaction.

Jump to

Keyboard shortcuts

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