Model layer is "complete"

I don't really like how it is for now but I will learn about it later
This commit is contained in:
2025-08-09 12:02:16 +01:00
parent e76261d5d5
commit 89679d6bb6
26 changed files with 516 additions and 329 deletions
+2 -9
View File
@@ -57,17 +57,10 @@ func GetCategory(catID int64) (Category, error) {
return MapRepoCategory(category), err
}
func (cat *Category) Insert() error {
cfg := config.GetInstance()
func (cat *Category) Insert(tx *sql.Tx) error {
ctx := context.Background()
db, err := sql.Open(cfg.DBSys, "file:"+cfg.DBPath+"?_foreign_keys=on")
if err != nil {
return err
}
defer db.Close()
queries := repo.New(db)
queries := repo.New(tx)
res, err := queries.InsertCategory(ctx, cat.CategoryName)
if err != nil {
return err