schema

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package schema contains the Document contract, BaseDocument/BaseChild embed types, the CompiledDoc/Field metadata types, the oj struct-tag parser, and the Registry that stores every registered Document after compilation.

See TAD §2.1–§2.2 and PRD §10 for the full specification. Implemented in Phase 1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseFields

func ParseFields(t reflect.Type) ([]Field, []CompiledChild, error)

ParseFields reflects on a struct type and extracts its Field definitions. It skips fields belonging to embedded BaseDocument or BaseChild, and fields marked with `oj:"-"`.

func RegisterDependency

func RegisterDependency(reg Registry, appName, dependency string)

RegisterDependency is a package-level helper that allows recording dependencies between applications in the registry, to verify dependency-ordered registration.

func RegisterValidator

func RegisterValidator(name string, v Validator)

RegisterValidator registers a named Validator for use via oj:"validator=Name". Panics if a validator with the same name is registered twice. Call from package init() in the same package that defines the validator. See TAD §9.1.

Types

type Attachment

type Attachment string

Attachment is a file-reference string (path or URL).

type BaseChild

type BaseChild struct {
	ID       string `oj:"-"` // ULID — set by Document Engine
	ParentID string `oj:"-"` // ID of the parent Document record
	Idx      int    `oj:"-"` // position within the parent's child list
}

BaseChild provides the auto fields for child table records. Embed this as the first field of every child-table struct:

type EmployeeSkill struct {
    schema.BaseChild
    // ... your fields
}

See PRD §10.1 (EmployeeSkill example).

func (*BaseChild) Get

func (c *BaseChild) Get(field string) any

func (*BaseChild) GetID

func (c *BaseChild) GetID() string

func (*BaseChild) Set

func (c *BaseChild) Set(field string, value any) errors.Error

func (*BaseChild) SetID

func (c *BaseChild) SetID(id string)

type BaseDocument

type BaseDocument struct {
	ID         string    `oj:"-"` // ULID — set by Document Engine
	Name       string    `oj:"-"` // human-readable identifier
	Owner      string    `oj:"-"` // user ID who created the record
	CreatedAt  time.Time `oj:"-"`
	UpdatedAt  time.Time `oj:"-"`
	ModifiedBy string    `oj:"-"` // user ID who last modified
	DocStatus  int       `oj:"-"` // 0=Draft, 1=Submitted, 2=Cancelled
	Deleted    bool      `oj:"-"` // soft-delete flag
}

BaseDocument provides the auto fields declared in PRD §10.2 and a partial implementation of the Document interface. Embed this struct as the first field of every top-level Document struct:

type Employee struct {
    schema.BaseDocument
    // ... your fields
}

See PRD §10.2 and TAD §2.1.

func (*BaseDocument) Get

func (b *BaseDocument) Get(field string) any

Get and Set on BaseDocument handle the auto-fields only. Document structs that embed BaseDocument must override Get/Set to expose their own fields. The Registry compiler generates a reminder if Get/Set are not present.

func (*BaseDocument) GetID

func (b *BaseDocument) GetID() string

func (*BaseDocument) Set

func (b *BaseDocument) Set(field string, value any) errors.Error

func (*BaseDocument) SetID

func (b *BaseDocument) SetID(id string)

type Cardinality added in v0.1.6

type Cardinality string

Cardinality is the compile-time derived multiplicity of a Relationship. Derived, never stored: see Orjanda_relationship_model_proposal.md §3.2.

const (
	// CardinalityManyToOne — a plain schema.Link field.
	CardinalityManyToOne Cardinality = "many_to_one"
	// CardinalityOneToOne — a schema.Link field carrying oj:"unique".
	CardinalityOneToOne Cardinality = "one_to_one"
	// CardinalityOneToMany — an owned child table (non-junction).
	CardinalityOneToMany Cardinality = "one_to_many"
	// CardinalityManyToMany — a child table marked oj:"junction".
	CardinalityManyToMany Cardinality = "many_to_many"
)

type ColumnAlteration

type ColumnAlteration struct {
	// FieldName is the Go struct field name.
	FieldName string
	// ColumnName is the SQL column name being altered. Added for type-change
	// rendering (TAD §14's struct is silent on it; without it ALTER COLUMN
	// cannot be generated).
	ColumnName string
	// OldColumn is the previous DB column definition (dialect-specific).
	OldColumn string
	// NewColumn is the desired DB column definition.
	NewColumn string
}

ColumnAlteration describes a change to an existing column.

type CompiledChild

type CompiledChild struct {
	// FieldName is the parent struct field name (e.g. "Skills").
	FieldName string
	// TypeName is the Go type name of the child struct (e.g. "EmployeeSkill").
	TypeName string
	// DocType is the canonical DocType name for the child table
	// (snake_case of TypeName by default, or set explicitly via DocMeta).
	DocType string
	// TableName is the pluralized snake_case table name, derived from TypeName
	// by the exact same rule as main tables (camelToSnake + "s", TAD §1.4).
	// Computed once at compile time so no consumer can derive it differently.
	TableName string
	// Fields is the compiled field set of the child struct.
	Fields []Field
	// Junction marks a child table as a many-to-many junction
	// (oj:"junction"). Storage and engine mechanics are identical to any other
	// child table; the flag changes only relationship metadata at compile time
	// — the junction's Link fields become many_to_many edges between the parent
	// and their targets. See Orjanda_relationship_model_proposal.md §3.8.
	Junction bool
}

CompiledChild describes a child table embedded in a parent Document. See PRD §10.1 (EmployeeSkill example) and TAD §2.1.

type CompiledDoc

type CompiledDoc struct {
	// Name is the canonical DocType name (e.g. "Employee").
	Name string
	// App is the app.Definition.Name that registered this Document.
	App string
	// Module is the logical grouping within the Application.
	Module string
	// TableName is the SQL table name (plural snake_case of Name).
	TableName string
	// Searchable — see Meta.Searchable.
	Searchable bool
	// Submittable — see Meta.Submittable.
	Submittable bool
	// Icon — see Meta.Icon.
	Icon string
	// Description — see Meta.Description.
	Description string
	// TitleField — see Meta.TitleField.
	TitleField string
	// SortField — see Meta.SortField.
	SortField string
	// SortOrder — see Meta.SortOrder.
	SortOrder SortOrder
	// Fields is the ordered list of compiled fields (base fields excluded —
	// they live in BaseDocument and are prepended by the Registry compiler).
	Fields []Field
	// Permissions is the per-role permission list from DocMeta().
	Permissions []DocPermission
	// ChildTables is the list of embedded child table types.
	ChildTables []CompiledChild
	// AgentHidden excludes the entire DocType from agent tool generation.
	AgentHidden bool
}

CompiledDoc is the immutable, compiler-output record for one Document type. Produced by Registry.Compile() from a Document's struct reflection + DocMeta() return. All downstream subsystems (DAL, perm, agent) read from CompiledDoc rather than reflecting on the original struct. See TAD §2.1.

func (*CompiledDoc) ResolveTitle added in v0.1.6

func (d *CompiledDoc) ResolveTitle(record map[string]any) string

ResolveTitle renders a record's human-readable title from the TitleField expression (PRD §10.1 / TAD §2.1). Field values and literal separators are concatenated in expression order; field terms missing from the record (or with nil values) contribute nothing. Runs of whitespace collapse to a single space. Returns "" when no title expression is set or nothing resolves.

func (*CompiledDoc) TitleColumns added in v0.1.6

func (d *CompiledDoc) TitleColumns() []string

TitleColumns returns the DB columns of the field references in the TitleField expression, in expression order. Terms are resolved by Go field name or column name; unknown terms pass through unchanged. Literal separators produce no column. See TAD §2.1 and PRD §10.1.

type Currency

type Currency float64

Currency is a decimal value for monetary amounts.

type Date

type Date time.Time

Date is a time.Time constrained to calendar-date precision.

type DateTime

type DateTime time.Time

DateTime is a time.Time stored at full timestamp precision.

type DocPermission

type DocPermission struct {
	// Role is the role name this permission entry applies to (e.g. "HR Manager").
	Role string
	// CRUD flags.
	Read   bool
	Write  bool
	Create bool
	Delete bool
	// Submit controls whether the role may submit a Submittable Document.
	Submit bool
	// Match optionally restricts this permission to a subset of records.
	// Defaults to MatchAll (zero value).
	Match MatchType
}

DocPermission declares the CRUD capabilities granted to Role on this DocType. A list of DocPermission values is returned from DocMeta() and compiled into CompiledDoc.Permissions. See PRD §16.3 and TAD §2.1.

type Document

type Document interface {
	// DocMeta returns the static metadata for this Document type.
	DocMeta() Meta

	// GetID returns the record's primary key (ULID string).
	GetID() string
	// SetID sets the primary key. Called by the Document Engine on creation.
	SetID(string)

	// Get returns a field value by Go struct field name.
	// Used by the Document Engine for map-based I/O without reflection.
	Get(field string) any
	// Set sets a field value by Go struct field name.
	// Returns errors.CodeValidation if the field name is unknown.
	Set(field string, value any) errors.Error
}

Document is the interface every Orjanda business entity must satisfy. Embed schema.BaseDocument (or schema.BaseChild for child tables) to get the canonical auto fields and a zero-overhead implementation of GetID/SetID. Implement DocMeta() to supply module-level metadata. See TAD §2.1 and PRD §10.1.

type DynamicLink struct {
	RefDocType string `json:"doctype"`
	RefID      string `json:"id"`
}

DynamicLink is a polymorphic reference that can point at any registered DocType (or one of the optionally declared `targets=`). It is stored as two physical columns ({field}_doctype, {field}_id) and serializes to the wire as {"doctype","id"} — Orjanda_relationship_model_proposal.md §3.10.

type Field

type Field struct {
	// Name is the Go struct field name (e.g. "FirstName").
	Name string
	// DBColumn is the snake_case column name (e.g. "first_name").
	DBColumn string
	// Type identifies the storage and agent interpretation category.
	Type FieldType
	// Required — field must have a non-zero value on create/update.
	Required bool
	// Unique — uniqueness constraint enforced by the DB and Document Engine.
	Unique bool
	// Searchable — included in full-text search index.
	Searchable bool
	// Label is the human-readable field label for UI and agent descriptions.
	Label string
	// Options holds the enumerated allowed values from oj:"options=A|B|C".
	Options []string
	// Default holds the string-encoded default value from oj:"default=X".
	Default string
	// Format is an optional validation format string: "email", "url", "phone".
	Format string
	// LinkTarget is the DocType name that a Link field references.
	LinkTarget string
	// LinkTargets is the optionally-declared `targets=A|B|C` set for a
	// DynamicLink field. Empty means "any registered DocType" (backward
	// compatible). Populated only for FieldTypeDynamicLink. See
	// Orjanda_relationship_model_proposal.md §3.10.
	LinkTargets []string
	// LinkTargetTable is the SQL table name of LinkTarget, resolved at compile
	// time by Registry.Compile() so the DAL dialects can emit a DB-level
	// FOREIGN KEY ... REFERENCES <table> without reaching into the Registry
	// (see Orjanda_relationship_model_proposal.md §3.5). Populated only for
	// FieldTypeLink fields; empty otherwise.
	LinkTargetTable string
	// NoFK skips DB-level FOREIGN KEY generation for this Link field
	// (oj:"link=X,no_fk"). Escape hatch for rare cross-shard/multi-tenant
	// cases where a hard constraint is undesirable — advanced/discouraged.
	// See Orjanda_relationship_model_proposal.md §3.5.
	NoFK bool
	// OnDelete is the declared delete behavior for a Link field
	// (oj:"on_delete=restrict|cascade|set_null", default restrict). Empty on
	// non-Link fields. Enforced by the Document Engine (soft-delete semantics)
	// — see Orjanda_relationship_model_proposal.md §3.6.
	OnDelete OnDeleteAction
	// Inverse is the optional cosmetic inverse-relationship label declared with
	// oj:"inverse=Name"; surfaced as the InverseLabel of inbound Relationship
	// entries. See Orjanda_relationship_model_proposal.md §3.7.
	Inverse string
	// ChildTypeName is the Go type name of child structs for FieldTypeChildTable.
	ChildTypeName string
	// Precision is the decimal precision for Currency fields.
	Precision int
	// PermissionRole gates access to this field to identities holding the
	// given role (oj:"permission=role"). Empty string means no gate.
	PermissionRole string
	// Hidden excludes the field from the default UI and agent BaseSchema.
	Hidden bool
	// System marks a framework-managed field (id, owner, created_at, ...).
	// Hidden system fields stay sortable; hidden user-data fields do not
	// (REVIEW-2026-08-12 finding 10: order_by must not reveal hidden data).
	System bool
	// ReadOnly prevents modification after initial creation.
	ReadOnly bool
	// Computed marks a derived value that is not stored.
	Computed bool
	// AgentHint is additional plain-text context appended to the field's
	// JSON Schema description in agent tool definitions. See PRD §24.4.
	AgentHint string
	// ValidatorName holds the oj:"validator=Name" registered validator name.
	ValidatorName string
	// AgentHidden excludes the field from the agent BaseSchema entirely,
	// stronger than Hidden (which still appears in the DB/API). See TAD §12.2.
	AgentHidden bool
}

Field is the compiled metadata for one field of a Document. Built by the oj tag parser and stored in CompiledDoc.Fields. See TAD §2.1.

func (Field) Cardinality added in v0.1.6

func (f Field) Cardinality() Cardinality

Cardinality reports the relationship cardinality this Link field takes part in: one_to_one when the field is unique (the referencing table holds at most one row per target), otherwise many_to_one. Empty for non-Link fields. See Orjanda_relationship_model_proposal.md §3.5.

func (Field) ColumnNames added in v0.1.6

func (f Field) ColumnNames() []string

ColumnNames returns the ordered DB column names this Field occupies. Single- column fields return their one DBColumn; a DynamicLink returns its two split columns; a ChildTable returns none (children live in their own table). Used by the dialects and migrator so DDL and diff derive the same columns.

func (Field) DynamicColumns added in v0.1.6

func (f Field) DynamicColumns() (docTypeCol, idCol string)

ColName returns the suffix-split column names a DynamicLink field occupies. A DynamicLink is stored as two physical columns: {DBColumn}_doctype and {DBColumn}_id (Orjanda_relationship_model_proposal.md §3.10).

func (Field) IsSearchText added in v0.1.6

func (f Field) IsSearchText() bool

IsSearchText reports whether the field can participate in a LIKE-based full-text search (dialect FullTextSearch). Used by the "q" search fallback when a document declares no Searchable fields (TAD §2.1, §6.1 relationship picker).

type FieldType

type FieldType string

FieldType is a stable string identifier for a field's storage and interpretation category. Used in CompiledDoc.Fields. See PRD §10.3.

const (
	FieldTypeString      FieldType = "string"
	FieldTypeInt         FieldType = "int"
	FieldTypeInt64       FieldType = "int64"
	FieldTypeFloat64     FieldType = "float64"
	FieldTypeBool        FieldType = "bool"
	FieldTypeDate        FieldType = "date"
	FieldTypeDateTime    FieldType = "datetime"
	FieldTypeCurrency    FieldType = "currency"
	FieldTypeText        FieldType = "text"
	FieldTypeRichText    FieldType = "richtext"
	FieldTypeLink        FieldType = "link"
	FieldTypeDynamicLink FieldType = "dynamiclink"
	FieldTypeAttachment  FieldType = "attachment"
	FieldTypeJSON        FieldType = "json"
	FieldTypeChildTable  FieldType = "child_table"
)

type ForeignKeyAction added in v0.1.6

type ForeignKeyAction string

ForeignKeyAction is the kind of change a ForeignKeyConstraint represents relative to the live database. See Orjanda_relationship_model_proposal.md §5.1.

const (
	// FKAdd means the FK exists in the Registry but not in the live database.
	FKAdd ForeignKeyAction = "ADD"
	// FKDrop means the FK exists in the live database but the Registry no
	// longer declares it (e.g. the Link field was removed, marked `no_fk`, or
	// its target changed). Destructive — gated by --allow-destructive.
	FKDrop ForeignKeyAction = "DROP"
	// FKChange means the FK exists on both sides but its ON DELETE behavior
	// (or target) differs. Destructive — gated by --allow-destructive.
	FKChange ForeignKeyAction = "CHANGE"
)

type ForeignKeyConstraint added in v0.1.6

type ForeignKeyConstraint struct {
	// Table is the referencing table holding the foreign key column.
	Table string
	// Column is the referencing (child) column.
	Column string
	// RefTable is the referenced (parent) table.
	RefTable string
	// RefColumn is the referenced parent column (always "id" in Orjanda).
	RefColumn string
	// OnDelete is the desired ON DELETE action (RESTRICT/CASCADE/SET NULL).
	// For a CHANGE it also reflects the desired (new) action.
	OnDelete OnDeleteAction
	// Action is ADD, DROP, or CHANGE.
	Action ForeignKeyAction
}

ForeignKeyConstraint is a single FK delta produced by Migrator.Diff. Rendered by dal.Dialect.AddForeignKey/DropForeignKey into the Goose Up block (Phase 3). See Orjanda_relationship_model_proposal.md §5.1.

type JSON

type JSON []byte

JSON is a raw JSON payload stored as JSONB (PostgreSQL) or TEXT (SQLite).

type Link string

Link is the Go type for a foreign-key reference to another Document.

type MatchType

type MatchType int

MatchType qualifies a DocPermission to restrict it to a subset of records. See PRD §16.2.

const (
	// MatchAll (zero value) allows access to every record of the DocType.
	MatchAll MatchType = 0
	// OwnerMatch restricts access to records whose Owner field equals the
	// calling user's ID. Evaluated by perm.Engine at runtime (Phase 4).
	OwnerMatch MatchType = 1
)

type Meta

type Meta struct {
	// Name is the canonical DocType name (e.g. "Employee"). Must be unique
	// within the Registry. Required.
	Name string
	// Module is the logical grouping within the Application (e.g. "HR").
	// Used by the Admin UI sidebar. Optional.
	Module string
	// Searchable marks the DocType as full-text searchable.
	// Generates a search_* agent tool (TAD §10.1 step 1).
	Searchable bool
	// Submittable marks the DocType as having a submission lifecycle.
	// Adds DocStatus field handling (PRD §10.2).
	Submittable bool
	// Icon is a UI hint for the Admin UI sidebar icon.
	Icon string
	// Description is a human-readable summary surfaced in the UI and Metadata API.
	Description string
	// AgentHidden excludes the entire DocType from agent tool generation
	// (TAD §10.1 — the schema-level agent_hidden flag, distinct from the
	// per-field hidden/agent_hidden tags of PRD §10.4 / TAD §12.2).
	AgentHidden bool
	// TitleField is the expression (field name or "First + Last" style) that
	// produces a human-readable record title in list views. See PRD §10.1.
	TitleField string
	// SortField is the default sort field for list queries.
	SortField string
	// SortOrder is Ascending (default) or Descending.
	SortOrder SortOrder
	// Permissions declares per-role CRUD grants for this DocType.
	Permissions []DocPermission
}

Meta is the structured metadata a Document developer returns from DocMeta(). Fields here override or supplement what the oj struct-tag parser can derive from the struct alone. See PRD §10.1 and TAD §2.1.

type OnDeleteAction added in v0.1.6

type OnDeleteAction string

OnDeleteAction is the declared referential behavior applied when the record a Link points to is deleted. See Orjanda_relationship_model_proposal.md §3.6.

const (
	// OnDeleteRestrict (default) — deletion is refused while referencing rows
	// exist in an active (non-soft-deleted) state.
	OnDeleteRestrict OnDeleteAction = "restrict"
	// OnDeleteCascade — referencing rows are soft-deleted with the target.
	OnDeleteCascade OnDeleteAction = "cascade"
	// OnDeleteSetNull — the Link column of referencing rows is nulled. Only
	// legal on non-required Links (compile-time fatal otherwise).
	OnDeleteSetNull OnDeleteAction = "set_null"
)

func NormalizeOnDeleteAction added in v0.1.6

func NormalizeOnDeleteAction(sql string) OnDeleteAction

NormalizeOnDeleteAction converts a SQL ON DELETE action string (as reported by database introspection, e.g. "SET NULL", "CASCADE", "RESTRICT", "NO ACTION") to the corresponding schema.OnDeleteAction enum value. Returns OnDeleteRestrict for unrecognized values (matching the SQL default).

type Registry

type Registry interface {
	Get(docType string) (*CompiledDoc, error)
	List() []*CompiledDoc
	Relationships(docType string) []Relationship
	Register(app string, doc Document) error
	Compile() error
}

Registry is the core read-only metadata catalog for all Documents. Built during startup compilation (TAD §3.1).

func NewRegistry

func NewRegistry() Registry

NewRegistry creates a new, uncompiled schema.Registry instance.

type Relationship

type Relationship struct {
	// FromDoc is the DocType that declares the link (outbound) or that holds
	// the reference reaching this DocType (inbound).
	FromDoc string
	// FromField is the field name on FromDoc that holds the reference. For a
	// many-to-many edge it is the parent child-table field carrying the
	// junction.
	FromField string
	// ToDoc is the target DocType.
	ToDoc string
	// IsChildTable is true when the relationship is backed by a child table
	// (ownership one_to_many or a many_to_many junction), false when it is a
	// Link (foreign key).
	IsChildTable bool
	// Direction is outbound when the relationship is declared on the queried
	// DocType, or inbound when synthesized from another DocType referencing it.
	Direction RelationshipDirection
	// Cardinality is derived at compile time: many_to_one (Link), one_to_one
	// (Link + unique), one_to_many (child table), many_to_many (junction).
	Cardinality Cardinality
	// InverseLabel is the human-readable label of the inverse edge:
	// oj:"inverse=X" on the declaring field, or a synthesized default (the
	// pluralized declaring DocType).
	InverseLabel string
	// OnDelete is the declared delete behavior of a Link edge ("" for child
	// table and virtual inbound edges when the field was non-Link).
	OnDelete OnDeleteAction
	// ViaJunction is non-empty only for many_to_many edges; it names the child
	// DocType that backs the junction (e.g. "project_member").
	ViaJunction string
	// ViaField is non-empty only for many_to_many edges; it names the junction
	// child's Link field through which the edge reaches ToDoc (e.g. "User").
	// The Admin UI uses it to read/write the junction rows when editing the
	// owning Document's child array. See registry.go junction resolution.
	ViaField string
}

Relationship describes a link between two DocTypes in one direction. Returned by Registry.Relationships() for the Agent Runtime and Metadata API. Each edge appears twice — once per participating DocType — with Direction indicating the queried side; inbound entries are virtual (resolved by listing the referencing DocType filtered on FromField, never by fetching a stored array). See PRD §10.5 step 3 and Orjanda_relationship_model_proposal.md §3.7.

type RelationshipDirection added in v0.1.6

type RelationshipDirection string

RelationshipDirection indicates whether a Relationship is declared on the queried DocType ("outbound") or synthesized because another DocType holds a Link reaching it ("inbound"). See PRD §10.5 step 3.

const (
	// DirectionOutbound — the relationship is declared as a field (or child
	// table) on the DocType being queried.
	DirectionOutbound RelationshipDirection = "outbound"
	// DirectionInbound — the relationship is virtual: another DocType holds
	// the Link (or junction) that reaches this DocType. No backing column.
	DirectionInbound RelationshipDirection = "inbound"
)

type RichText

type RichText string

RichText is a formatted-content string stored as TEXT.

type SchemaDiff

type SchemaDiff struct {
	// CreateTables is the list of new DocTypes that need a CREATE TABLE.
	CreateTables []CompiledDoc
	// AlterTables is the list of existing tables with column changes.
	AlterTables []TableAlteration
	// DropTables lists orphaned Orjanda-owned tables that exist in the live
	// database but are no longer produced by the Registry (requires
	// --allow-destructive, see TAD §14.1 step 2).
	DropTables []string
	// ForeignKeys lists FK deltas (add/drop/change). DROP and CHANGE are
	// destructive — gated by --allow-destructive (proposal §5.1).
	ForeignKeys []ForeignKeyConstraint
}

SchemaDiff represents the delta between the compiled Registry and the live database schema. Used by dal.Migrator (Phase 2). Defined here so the schema package owns the type and dal.Dialect can import it without a cycle. See TAD §2.3 and §14.

func (*SchemaDiff) ChangeCount

func (d *SchemaDiff) ChangeCount() int

ChangeCount returns the total number of pending schema changes across all diff categories. Used by the production serve fail-fast gate and `migrate diff`'s "no schema changes" check (REVIEW-2026-08-12 finding 9: dropped tables must count). FK changes count as pending so a synced DB with only FK drift still blocks production startup.

type SortOrder

type SortOrder int

SortOrder indicates ascending or descending sort. Used in Meta.SortOrder.

const (
	Ascending  SortOrder = 0
	Descending SortOrder = 1
)

type TableAlteration

type TableAlteration struct {
	// TableName is the SQL table name being altered.
	TableName string
	// AddColumns is the list of new fields to add as columns.
	AddColumns []Field
	// DropColumns lists column names to drop (requires --allow-destructive).
	DropColumns []string
	// AlterColumns lists columns whose type or constraints have changed.
	AlterColumns []ColumnAlteration
}

TableAlteration describes column-level changes to an existing table.

type Text

type Text string

Text is a long-text string stored as TEXT.

type Validator

type Validator interface {
	// Validate returns nil if the value passes, or an errors.Error with
	// Code() == errors.CodeValidation on failure.
	Validate(ctx context.Context, field Field, value any) error
}

Validator is the extension point for custom field validation logic. Registered via oj:"validator=Name" + schema.RegisterValidator("Name", v). Called by the Document Engine during the validate phase (Phase 4). See TAD §9.1 and PRD §20.2.

func LookupValidator

func LookupValidator(name string) Validator

LookupValidator returns the Validator registered under name, or nil if none. Used by the Document Engine during validation (Phase 4).

Jump to

Keyboard shortcuts

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