Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB wraps *sqlx.DB with app-specific helpers.
func New ¶
New opens (or creates) the SQLite database at the path specified in cfg. The path is resolved relative to the running binary's directory so the database file always sits next to the executable.
func (*DB) Migrate ¶
Migrate applies all pending goose migrations embedded in the migrations package. Safe to call on every startup — already-applied migrations are skipped automatically.
func (*DB) PluckHashes ¶
func (db *DB) PluckHashes(ctx context.Context, table, keyCol, hashCol string) (map[int32]string, error)
PluckHashes returns column[keyCol] -> column[hashCol] for every row of table. Used for cheap change-detection passes (e.g. beatmap_id -> md5_hash) without pulling full rows into memory.
func (*DB) UpsertBatch ¶
UpsertBatch writes rows (must be a slice of a struct with `db` tags, e.g. []model.Beatmap) into table in chunks sized to stay under sqliteMaxVariableNumber, all inside one transaction. conflictCols are the PK/unique columns used for ON CONFLICT ... DO UPDATE.
err := db.UpsertBatch(ctx, "beatmaps", []string{"beatmap_id"}, beatmaps)