Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var OrderMeta = drel.ModelMeta[Order]{ Table: "orders", Columns: []string{"id", "customer", "total", "status", "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] Status drel.StringColumn CreatedAt drel.TimeColumn UpdatedAt drel.TimeColumn }{ ID: drel.NewComparableCol[uuid.UUID]("id"), Customer: drel.NewStringCol("customer"), Total: drel.NewOrderedCol[int]("total"), Status: drel.NewStringCol("status"), 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"`
Status string `db:"status,index"`
}
Order is a SQLite-backed model that raises domain events from its behaviour. Embedding drel.Model[uuid.UUID] gives it an application-assigned UUIDv7 primary key (stamped at Add() time), plus ID(), RecordEvent and the change-tracking hooks the outbox relies on.
type OrderPlaced ¶
type OrderPlaced struct {
OrderID uuid.UUID `json:"order_id"`
Customer string `json:"customer"`
Total int `json:"total_cents"`
}
OrderPlaced is recorded when a new order is accepted.
type OrderRepository ¶
type OrderRepository struct {
*drel.Repository[Order]
}
type OrderShipped ¶
OrderShipped is recorded when an order is dispatched to a carrier.
type TxOrderRepository ¶
type TxOrderRepository struct {
*drel.TxRepository[Order]
}
Click to show internal directories.
Click to hide internal directories.