schema

package
v0.0.0-...-cb5b6c1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package schema defines declaration-time entity values.

Index

Constants

View Source
const (
	FieldID     = declaration.FieldID
	FieldText   = declaration.FieldText
	FieldInt    = declaration.FieldInt
	FieldInt64  = declaration.FieldInt64
	FieldInt32  = declaration.FieldInt32
	FieldFloat  = declaration.FieldFloat
	FieldBool   = declaration.FieldBool
	FieldTime   = declaration.FieldTime
	FieldUUID   = declaration.FieldUUID
	FieldBytes  = declaration.FieldBytes
	FieldEnum   = declaration.FieldEnum
	FieldJSONB  = declaration.FieldJSONB
	FieldArray  = declaration.FieldArray
	FieldCustom = declaration.FieldCustom
)

Supported field kinds.

View Source
const (
	EdgeBelongsTo  = declaration.EdgeBelongsTo
	EdgeManyToMany = declaration.EdgeManyToMany
)

Supported edge kinds.

View Source
const (
	DeleteNoAction = declaration.DeleteNoAction
	DeleteCascade  = declaration.DeleteCascade
	DeleteRestrict = declaration.DeleteRestrict
	DeleteSetNull  = declaration.DeleteSetNull
)

Supported foreign-key deletion actions.

View Source
const (
	IndexBTree = declaration.IndexBTree
	IndexGIN   = declaration.IndexGIN
)

Supported index methods.

Variables

This section is empty.

Functions

func Validate

func Validate(entity Entity) error

Validate checks declaration rules which do not require resolving the full schema graph. Graph-wide validation is performed by the loader.

Types

type Annotation

type Annotation = declaration.Annotation

Annotation is opaque extension metadata preserved by the loader.

type Annotations

type Annotations []Annotation

Annotations is an ordered collection of extension metadata.

type Check

type Check = declaration.Check

Check is an immutable check constraint declaration.

type Checks

type Checks []Check

Checks is an ordered collection of check constraint declarations.

type Config

type Config struct {
	Name       string
	Table      string
	GoName     string
	RenameFrom string
	Keyless    bool
}

Config overrides names derived for an entity.

type DefaultFunc

type DefaultFunc = declaration.DefaultFunc

DefaultFunc represents an application default evaluated once for each row.

func Func

func Func[T any](fn func() T) DefaultFunc

Func creates an infallible per-row default.

func FuncErr

func FuncErr[T any](fn func() (T, error)) DefaultFunc

FuncErr creates a per-row default which may fail.

type DeleteAction

type DeleteAction = declaration.DeleteAction

DeleteAction controls foreign-key deletion behavior.

type Edge

type Edge = declaration.Edge

Edge is an immutable relationship declaration.

type EdgeKind

type EdgeKind = declaration.EdgeKind

EdgeKind identifies relationship cardinality.

type Edges

type Edges []Edge

Edges is an ordered collection of edge declarations.

type Entity

type Entity struct {
	Name        string
	Table       string
	GoName      string
	Fields      Fields
	Edges       Edges
	Mixins      Mixins
	Indexes     Indexes
	Checks      Checks
	Annotations Annotations
	Comment     string
	RenamedFrom string
	Keyless     bool
}

Entity is an evaluated, unresolved schema declaration.

type Field

type Field = declaration.Field

Field is an immutable field declaration.

type FieldKind

type FieldKind = declaration.FieldKind

FieldKind identifies a built-in field representation.

type Fields

type Fields []Field

Fields is an ordered collection of field declarations.

type Index

type Index = declaration.Index

Index is an immutable index declaration.

type IndexColumn

type IndexColumn = declaration.IndexColumn

IndexColumn is an immutable per-column index option declaration.

type IndexDirection

type IndexDirection = declaration.IndexDirection

IndexDirection controls the ordering of an index column.

type IndexMethod

type IndexMethod = declaration.IndexMethod

IndexMethod identifies a database index method.

type IndexNulls

type IndexNulls = declaration.IndexNulls

IndexNulls controls the placement of NULL values in an index column.

type Indexes

type Indexes []Index

Indexes is an ordered collection of index declarations.

type Interface

type Interface interface {
	Type()
	Config() Config
	Fields() Fields
	Edges() Edges
	Indexes() Indexes
	Checks() Checks
	Mixins() Mixins
	Annotations() Annotations
}

Interface is implemented by every discoverable schema entity.

type Mixin

type Mixin struct {
	Fields  Fields
	Edges   Edges
	Indexes Indexes
}

Mixin contains reusable declarations prepended to an entity.

type Mixins

type Mixins []Mixin

Mixins is an ordered collection of reusable declarations.

type Schema

type Schema struct{}

Schema supplies no-op defaults for schema entities. Type exists so promoted method expressions, such as User.Type, can be used as compile-checked edge targets.

func (Schema) Annotations

func (Schema) Annotations() Annotations

Annotations returns no annotations.

func (Schema) Checks

func (Schema) Checks() Checks

Checks returns no check constraints.

func (Schema) Config

func (Schema) Config() Config

Config returns empty entity configuration.

func (Schema) Edges

func (Schema) Edges() Edges

Edges returns no edges.

func (Schema) Fields

func (Schema) Fields() Fields

Fields returns no fields.

func (Schema) Indexes

func (Schema) Indexes() Indexes

Indexes returns no indexes.

func (Schema) Mixins

func (Schema) Mixins() Mixins

Mixins returns no mixins.

func (Schema) Type

func (Schema) Type()

Type identifies the concrete schema type through a promoted method expression.

Directories

Path Synopsis
Package check declares application-level SQL check constraints.
Package check declares application-level SQL check constraints.
Package edge defines schema relationship builders.
Package edge defines schema relationship builders.
Package field defines typed schema field builders.
Package field defines typed schema field builders.
Package index defines schema index builders.
Package index defines schema index builders.
internal
Package mixin defines reusable groups of schema declarations, including application-side and database-side primary-key generators.
Package mixin defines reusable groups of schema declarations, including application-side and database-side primary-key generators.

Jump to

Keyboard shortcuts

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