Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Order

type Order struct {
	ID            uuid.UUID      `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
	UserID        uuid.UUID      `gorm:"type:uuid;not null" json:"user_id"`
	Description   string         `gorm:"not null" json:"description"`
	TotalPrice    float64        `gorm:"not null" json:"total_price"`
	Status        string         `gorm:"not null" json:"status"`
	CreatedAt     time.Time      `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt     time.Time      `gorm:"autoUpdateTime" json:"updated_at"`
	OrderProducts []OrderProduct `gorm:"foreignKey:OrderID" json:"order_products,omitempty"`
}

type OrderProduct

type OrderProduct struct {
	OrderID   uuid.UUID `gorm:"type:uuid;primaryKey" json:"order_id"`
	ProductID uuid.UUID `gorm:"type:uuid;primaryKey" json:"product_id"`
	Quantity  int       `gorm:"not null" json:"quantity"`
	Price     float64   `gorm:"not null" json:"price"` // Price at time of order
	Product   Product   `gorm:"foreignKey:ProductID" json:"product,omitempty"`
}

OrderProduct represents the join table between orders and products

type Product

type Product struct {
	ID          uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
	Name        string    `gorm:"not null" json:"name"`
	Description string    `gorm:"not null" json:"description"`
	Price       float64   `gorm:"not null" json:"price"`
	Stock       int64     `gorm:"not null" json:"stock"`
	Category    string    `gorm:"not null" json:"category"`
	ImageURL    string    `gorm:"default:null" json:"imageUrl,omitempty"`
	UserID      uuid.UUID `gorm:"type:uuid;not null" json:"user_id"`
}

type User

type User struct {
	ID       uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
	Username string    `gorm:"uniqueIndex;not null" json:"username"`
	Email    string    `gorm:"uniqueIndex;not null" json:"email"`
	Password string    `gorm:"not null" json:"-"`
	Role     string    `gorm:"default:'user';not null" json:"role"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL