widget

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAdmin

func RegisterAdmin(app *framework.App) error

RegisterAdmin registers Widget on the runtime admin. Feature packages own this call — the framework never discovers GORM models by itself (ADR-013).

Fields is left empty so admin.FieldsFrom derives the schema from the GORM model, including the three relations (#223): warehouse_id auto-derives to a belongs_to picker, warehouses to a many_to_many multi-select, and parts to a read-only has_many view — no per-field wiring, no per-model React file.

Types

type Widget

type Widget struct {
	ID   uint   `gorm:"primaryKey" json:"id"`
	Name string `json:"name"`
	SKU  string `json:"sku"`

	// belongs_to: the widget's primary warehouse (FK + association). The FK is a
	// *uint so it is genuinely optional: a widget with no warehouse stores NULL
	// rather than 0, which a non-nullable uint could not represent under foreign
	// key enforcement (the admin advertises belongs_to as optional, so the create
	// must actually accept "none").
	WarehouseID *uint               `gorm:"index" json:"warehouse_id"`
	Warehouse   warehouse.Warehouse `json:"-"`

	// many_to_many: every warehouse this widget is stocked at (join table). The
	// JSON name is the admin field name the multi-select binds to.
	Warehouses []warehouse.Warehouse `gorm:"many2many:widget_warehouses;" json:"warehouses"`

	// has_many: the widget's parts (read-only in the admin; Part carries the FK).
	Parts []part.Part `json:"parts"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Widget is the model registered with the admin in this example. It carries all three relation kinds so the admin renders their widgets from the registry alone (ADR-013 / #223): a belongs_to picker, a many_to_many multi-select, and a read-only has_many view.

Jump to

Keyboard shortcuts

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