Documentation
¶
Overview ¶
Package schema defines declaration-time entity values.
Index ¶
- Constants
- func Validate(entity Entity) error
- type Annotation
- type Annotations
- type Check
- type Checks
- type Config
- type DefaultFunc
- type DeleteAction
- type Edge
- type EdgeKind
- type Edges
- type Entity
- type Field
- type FieldKind
- type Fields
- type Index
- type IndexColumn
- type IndexDirection
- type IndexMethod
- type IndexNulls
- type Indexes
- type Interface
- type Mixin
- type Mixins
- type Schema
Constants ¶
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.
const ( EdgeBelongsTo = declaration.EdgeBelongsTo EdgeManyToMany = declaration.EdgeManyToMany )
Supported edge kinds.
const ( DeleteNoAction = declaration.DeleteNoAction DeleteCascade = declaration.DeleteCascade DeleteRestrict = declaration.DeleteRestrict DeleteSetNull = declaration.DeleteSetNull )
Supported foreign-key deletion actions.
const ( IndexBTree = declaration.IndexBTree IndexGIN = declaration.IndexGIN )
Supported index methods.
Variables ¶
This section is empty.
Functions ¶
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 DefaultFunc ¶
type DefaultFunc = declaration.DefaultFunc
DefaultFunc represents an application default evaluated once for each row.
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 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 FieldKind ¶
type FieldKind = declaration.FieldKind
FieldKind identifies a built-in field representation.
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 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 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.
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. |