model

package
v0.0.0-...-876b2d5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Customer

type Customer struct {
	ID   int    `json:"id,omitempty"`
	Name string `json:"name" pg:",notnull"`
}

Customer is a model in the "customers" table.

type Order

type Order struct {
	ID       int     `json:"id,omitempty"`
	Subtotal float64 `json:"subtotal,string" pg:"type:'decimal(18,2)'"`

	Customer   Customer `json:"customer" pg:"fk:customer_id,rel:has-one"`
	CustomerID int      `json:"-"`

	Products []Product `json:"products" pg:"many2many:order_products"`
}

Order is a model in the "orders" table.

type OrderProduct

type OrderProduct struct {
	Order   Order `json:"order" pg:"fk:order_id,on_delete:CASCADE,rel:has-one"`
	OrderID int   `json:"-"`

	Product   Product `json:"product" pg:"fk:product_id,rel:has-one"`
	ProductID int     `json:"-"`
}

OrderProduct is a model in the "order_products" table.

type Product

type Product struct {
	ID    int     `json:"id,omitempty"`
	Name  string  `json:"name" pg:",notnull,unique"`
	Price float64 `json:"price,string" pg:"type:'decimal(18,2)'"`
}

Product is a model in the "products" table.

Jump to

Keyboard shortcuts

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