Whatever I'm doing here I think I will regret it, sqlc migration

This commit is contained in:
2025-08-05 13:57:37 +01:00
parent b194818c93
commit 31f596a150
40 changed files with 715 additions and 269 deletions
+5 -11
View File
@@ -11,32 +11,26 @@ import (
_ "github.com/mattn/go-sqlite3"
)
type ExpenseShare struct {
ExpShareID int
User User
Share float32
}
func GetShares(expID int64) ([]repository.GetSharesRow, error) {
func GetShares(expID int64) ([]ExpenseShare, error) {
cfg := config.GetInstance()
ctx := context.Background()
db, err := sql.Open(cfg.DBSys, cfg.DBPath)
if err != nil {
return []repository.GetSharesRow{}, err
return []ExpenseShare{}, err
}
defer db.Close()
queries := repository.New(db)
shares, err := queries.GetShares(ctx, expID)
if err != nil {
return []repository.GetSharesRow{}, err
return []ExpenseShare{}, err
}
return shares, nil
return mapRepoGetSharesRows(shares), nil
}
func (sh *ExpenseShare) Insert(expID int) error {
func (sh *ExpenseShare) Insert(expID int64) error {
cfg := config.GetInstance()
db, err := sql.Open(cfg.DBSys, "file:"+cfg.DBPath+"?_foreign_keys=on")