diff options
author | Thomas Voss <mail@thomasvoss.com> | 2025-06-09 02:51:27 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2025-06-09 02:51:27 +0200 |
commit | 52db1d03e5067de4ba77c3a12465149d268eb3d1 (patch) | |
tree | 96286b94957e2546a789cbdcad2677b6f03b0973 /src/dbx/mintages.go | |
parent | 09defec0a015e7ddb118bd453ea2925a5cb9d5dc (diff) |
Begin migration towards SQLite
Diffstat (limited to 'src/dbx/mintages.go')
-rw-r--r-- | src/dbx/mintages.go | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/dbx/mintages.go b/src/dbx/mintages.go new file mode 100644 index 0000000..96cc871 --- /dev/null +++ b/src/dbx/mintages.go @@ -0,0 +1,65 @@ +package dbx + +type MintageData struct { + Standard []MSRow + Commemorative []MCRow +} + +type MSRow struct { + Type int `db:"type"` + Year int `db:"year"` + Mintmark string `db:"mintmark"` + Mintages [ndenoms]int `db:"array;€0,01;€0,02;€0,05;€0,10;€0,20;€0,50;€1,00;€2,00"` + Reference string `db:"reference"` +} + +type MCRow struct { + Type int `db:"type"` + Year int `db:"year"` + Name string `db:"name"` + Number int `db:"number"` + Mintmark string `db:"mintmark"` + Mintage int `db:"mintage"` + Reference string `db:"reference"` +} + +/* DO NOT REORDER! */ +const ( + TypeCirc = iota + TypeNifc + TypeProof +) + +/* DO NOT REORDER! */ +const ( + MintageUnknown = -iota - 1 + MintageInvalid +) + +const ndenoms = 8 + +func GetMintages(country string) (MintageData, error) { + var zero MintageData + + srows, err := DB.Query(`SELECT * FROM mintages_s WHERE country = ?`, country) + if err != nil { + return zero, err + } + defer srows.Close() + xs, err := scanToStructs[MSRow](srows) + if err != nil { + return zero, err + } + + crows, err := DB.Query(`SELECT * FROM mintages_c WHERE country = ?`, country) + if err != nil { + return zero, err + } + defer crows.Close() + ys, err := scanToStructs[MCRow](crows) + if err != nil { + return zero, err + } + + return MintageData{xs, ys}, nil +} |