Documentation
¶
Overview ¶
Package model defines wowapi's base model primitives: embeddable structs for identity, tenancy, audit, versioning, temporal validity, and status; plus kernel-wide value objects for money, references, and time ranges.
Composition rules and anti-patterns are specified in docs/blueprint/04-project-and-primitives.md §3. The key principle is composition over a god BaseModel — each entity embeds only the structs whose corresponding columns it actually carries.
Import boundary: stdlib + github.com/google/uuid + github.com/shopspring/decimal only. This package is at the base of the dependency graph; adding anything else here pulls it into every consumer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActorKind ¶
type ActorKind string
ActorKind identifies the kind of principal performing an action.
type ActorRef ¶
ActorRef identifies who performed an action. Only one of UserID, CapacityID, or System is meaningful for a given Kind; the others carry zero values.
type Auditable ¶
type Auditable struct {
CreatedAt time.Time `db:"created_at"`
CreatedBy uuid.UUID `db:"created_by"`
UpdatedAt *time.Time `db:"updated_at"`
UpdatedBy *uuid.UUID `db:"updated_by"`
}
Auditable records who created and last modified a row. Embed in mutable entities. NOT for append-only rows — use CreatedOnly there.
type BaseFields ¶
BaseFields carries identity only. Embed in every persisted entity.
type CreatedOnly ¶
type CreatedOnly struct {
CreatedAt time.Time `db:"created_at"`
CreatedBy uuid.UUID `db:"created_by"`
}
CreatedOnly is the append-only variant of Auditable. Once a row is inserted its authorship is immutable; there is no UpdatedAt/UpdatedBy column.
type ExternalRef ¶
ExternalRef is a pointer into an external system (e.g. Stripe, Salesforce).
type IDGen ¶
IDGen produces primary keys. Injected everywhere IDs are minted so tests can run deterministic sequences (docs/blueprint/03 §1: UUIDv7, app-generated).
type Metadata ¶
Metadata is a schema-free extension bag for module-declared display extras. It must never drive core logic — the moment code branches on a key, promote that key to a typed column.
type Money ¶
Money is an exact monetary amount. Amount uses shopspring/decimal to avoid floating-point error. The DB representation is numeric + char(3).
type ResourceRef ¶
ResourceRef is a kernel-wide pointer to any domain object. It is used wherever code must reference an entity without importing that entity's package.
type Statused ¶
type Statused[S ~string] struct { Status S `db:"status"` }
Statused carries a lifecycle status using a typed string constant. Embed instead of soft-delete booleans; status vocabulary is per-entity.
type Temporal ¶
Temporal carries a validity window for history-aware rows (assignments, relationships, grants). Only embed where "as-of" queries are a real requirement — every temporal table pays query complexity forever.
type TenantScoped ¶
TenantScoped marks an entity as tenant-owned. Repo helpers key on the presence of this struct — an entity without it cannot use TenantDB write helpers.