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
@@ -7,6 +7,7 @@ package repository
import (
"context"
"database/sql"
)
const getExpense = `-- name: GetExpense :one
@@ -130,3 +131,39 @@ func (q *Queries) GetExpenses(ctx context.Context) ([]GetExpensesRow, error) {
}
return items, nil
}
const insertExpense = `-- name: InsertExpense :execresult
INSERT INTO expenses(
"Description","Value",
"StoreID",
"CategoryID",
"TypeID",
"OwnerUserID",
"ExpDate","CreationDate"
)
VALUES(?, ?, ? , ?, ?, ?, ?, ?)
`
type InsertExpenseParams struct {
Description string
Value float64
StoreID int64
CategoryID int64
TypeID int64
OwnerUserID int64
ExpDate int64
CreationDate int64
}
func (q *Queries) InsertExpense(ctx context.Context, arg InsertExpenseParams) (sql.Result, error) {
return q.db.ExecContext(ctx, insertExpense,
arg.Description,
arg.Value,
arg.StoreID,
arg.CategoryID,
arg.TypeID,
arg.OwnerUserID,
arg.ExpDate,
arg.CreationDate,
)
}