db

package
v0.0.0-...-377b65c Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package db contains utilities to record train sightings in a SQLite db.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRowAffected = errors.New("no rows affected")

ErrNoRowAffected means that a row was expected to change - but none did.

Functions

func Backup

func Backup(src *sqlx.DB, destPath string) error

Backup safely backs up a SQLite database to a new file.

func GetAllBlobs

func GetAllBlobs(db *sqlx.DB) (map[string]struct{}, error)

GetAllBlobs lists all blobs which the database knows about. Does not include thumbnails.

func InsertTrain

func InsertTrain(db *sqlx.DB, t stitch.Train) (int64, error)

InsertTrain inserts a new train sighting into the database. Returns the db id of the new row.

func Open

func Open(path string) (*sqlx.DB, error)

Open creates a new SQLite database or opens an existing one. Will run the schema/migration script.

func SetCleanedUp

func SetCleanedUp(db *sqlx.DB, id int64) error

SetCleanedUp marks a train sighting as uploaded in the database.

func SetUploaded

func SetUploaded(db *sqlx.DB, id int64) error

SetUploaded marks a train sighting as uploaded in the database.

Types

type Train

type Train struct {
	ID      int64     `db:"id"`
	StartTS time.Time `db:"start_ts"`
}

Train represents the basics of a train in the database.

func GetNextCleanup

func GetNextCleanup(db *sqlx.DB) (*Train, error)

GetNextCleanup returns the next train sighting for which we can delete the blobs locally.

func GetNextUpload

func GetNextUpload(db *sqlx.DB) (*Train, error)

GetNextUpload returns the next train sighting to upload from the database.

func (*Train) GIFFileName

func (t *Train) GIFFileName() string

GIFFileName returns the GIF file name for this train (derived from timestamp).

func (*Train) ImgFileName

func (t *Train) ImgFileName() string

ImgFileName returns the image file name for this train (derived from timestamp).

Jump to

Keyboard shortcuts

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