Fucking git can't handle deleting a file that changed.

master
Zed A. Shaw 3 weeks ago
commit da6da800a0
  1. 1
      data/crud.go
  2. 21
      data/models.go
  3. 10
      features/init.go
  4. 13
      migrations/20260112190943_shopping_init.sql
  5. 13
      migrations/20260112195518_shopping_cart.sql

@ -28,6 +28,7 @@ func Shutdown() {
}
func SelectJson[T any](c *fiber.Ctx, err error, sql string, args ...interface{}) error {
// BUG: add a precondition that aborts if array of interfaces to avoid "unsupported $1 array of interfaces"
var result []T
if err != nil { goto fail }

@ -25,9 +25,30 @@ type NullExample struct {
HasMaybe null.Int `db:"replying_to" validate:"omitempty,numeric"`
}
type Product struct {
Id int `db:"id" validate:"numeric"`
Title string `db:"title" validate:"required"`
Description string `db:"description" validate:"required"`
Price float64 `db:"price" validate:"required"`
Slug string `db:"slug" validate:"required"`
}
type CartItem struct {
Id int `db:"id" validate:"numeric"`
UserId int `db:"user_id" validate:"numeric,required"`
ProductId int `db:"product_id" validate:"required"`
Quantity int `db:"quantity" validate:"numeric"`
}
type Cart struct {
Items []CartItem
}
func Models() map[string]reflect.Type {
return map[string]reflect.Type{
"user": reflect.TypeFor[User](),
"product": reflect.TypeFor[Product](),
"cart_item": reflect.TypeFor[CartItem](),
"null_example": reflect.TypeFor[NullExample](),
}
}

@ -2,11 +2,13 @@ package features
import (
"github.com/gofiber/fiber/v2"
email "MY/webapp/features/email"
paypal "MY/webapp/features/paypal"
"MY/webapp/features/email"
"MY/webapp/features/paypal"
"MY/webapp/features/shopping"
)
func Setup(app *fiber.App) {
email.Setup(app)
paypal.Setup(app)
features_email.Setup(app)
features_paypal.Setup(app)
features_shopping.Setup(app)
}

@ -0,0 +1,13 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE Product (id INTEGER PRIMARY KEY,
title TEXT,
description TEXT,
price float,
slug TEXT UNIQUE);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE Product;
-- +goose StatementEnd

@ -0,0 +1,13 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE Cart (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
quantity INTEGER);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE Cart;
-- +goose StatementEnd
Loading…
Cancel
Save