orders

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OrderMeta = drel.ModelMeta[Order]{
	Table:         "orders",
	Columns:       []string{"id", "customer", "total", "created_at", "updated_at"},
	PKColumns:     []string{"id"},
	Scan:          scanOrder,
	Snapshot:      snapshotOrder,
	Diff:          diffOrder,
	PKValue:       orderPKValue,
	InsertColumns: orderInsertColumns,
	ScanReturning: orderScanReturning,
	ColumnValue:   orderColumnValue,
	NormalizeKey:  orderNormalizeKey,
	KeyStrategy:   drel.KeyAppAssigned,
	GenerateKey:   drel.UUIDv7Key,
	SetKey:        func(p *Order, key any) { p.SetID(key.(uuid.UUID)) },
	KeyIsZero:     orderKeyIsZero,
	ScanGenerated: orderScanGenerated,
}
View Source
var Orders = struct {
	ID        drel.ComparableColumn[uuid.UUID]
	Customer  drel.StringColumn
	Total     drel.OrderedColumn[int]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	ID:        drel.NewComparableCol[uuid.UUID]("id"),
	Customer:  drel.NewStringCol("customer"),
	Total:     drel.NewOrderedCol[int]("total"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}

Functions

This section is empty.

Types

type Order

type Order struct {
	drel.Model[uuid.UUID]
	Customer string `db:"customer"`
	Total    int    `db:"total"`
}

Order uses an application-assigned UUIDv7 primary key. drel stamps a fresh v7 UUID at Add() time — the id is available before any flush.

func NewOrder

func NewOrder(customer string, total int) *Order

type OrderRepository

type OrderRepository struct {
	*drel.Repository[Order]
}

func (*OrderRepository) FindByID

func (r *OrderRepository) FindByID(ctx context.Context, id uuid.UUID) (*Order, error)

type TxOrderRepository

type TxOrderRepository struct {
	*drel.TxRepository[Order]
}

func (*TxOrderRepository) FindByID

func (r *TxOrderRepository) FindByID(ctx context.Context, id uuid.UUID) (*Order, error)

Jump to

Keyboard shortcuts

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