orders

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 4 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"},
	PKColumn:      "id",
	Scan:          scanOrder,
	Snapshot:      snapshotOrder,
	Diff:          diffOrder,
	PKValue:       orderPKValue,
	InsertColumns: orderInsertColumns,
	ScanReturning: orderScanReturning,
	ColumnValue:   orderColumnValue,
	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.Column[uuid.UUID]
	Customer  drel.StringColumn
	Total     drel.OrderedColumn[int]
	CreatedAt drel.Column[time.Time]
	UpdatedAt drel.Column[time.Time]
}{
	ID:        drel.NewCol[uuid.UUID]("id"),
	Customer:  drel.NewStringCol("customer"),
	Total:     drel.NewOrderedCol[int]("total"),
	CreatedAt: drel.NewCol[time.Time]("created_at"),
	UpdatedAt: drel.NewCol[time.Time]("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)

type UoWOrderRepository

type UoWOrderRepository struct {
	*drel.UoWRepository[Order]
}

func (*UoWOrderRepository) FindByID

func (r *UoWOrderRepository) 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