fields

package
v0.0.0-...-8e41c16 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Embed

func Embed(nameOrScan any, options ...EmbedOptions) func(d attrs.Definer) []attrs.Field

func ForeignKey

func ForeignKey[T any](name, columnName string, conf ...*FieldConfig) attrs.UnboundFieldConstructor

func GenericForeignKey

func GenericForeignKey[T attrs.Definer](definer T, name string, cnf *GenericForeignKeyConfig) interface{}

func ManyToMany

func ManyToMany[T any](name string, conf ...*FieldConfig) attrs.UnboundFieldConstructor

func OneToOne

func OneToOne[T any](name string, conf ...*FieldConfig) attrs.UnboundFieldConstructor

Types

type DataModelField

type DataModelField[T any] struct {
	// model is the model that this field belongs to
	Model attrs.Definer
	// contains filtered or unexported fields
}

func NewDataModelField

func NewDataModelField[T any](forModel attrs.Definer, dst any, name string, cnf ...DataModelFieldConfig) *DataModelField[T]

func (*DataModelField[T]) AllowBlank

func (e *DataModelField[T]) AllowBlank() bool

func (*DataModelField[T]) AllowDBEdit

func (e *DataModelField[T]) AllowDBEdit() bool

func (*DataModelField[T]) AllowEdit

func (e *DataModelField[T]) AllowEdit() bool

func (*DataModelField[T]) AllowNull

func (e *DataModelField[T]) AllowNull() bool

func (*DataModelField[T]) Attrs

func (e *DataModelField[T]) Attrs() map[string]any

func (*DataModelField[T]) BindToDefinitions

func (f *DataModelField[T]) BindToDefinitions(defs attrs.Definitions)

func (*DataModelField[T]) ColumnName

func (e *DataModelField[T]) ColumnName() string

no real column, special case for virtual fields

func (*DataModelField[T]) FieldDefinitions

func (f *DataModelField[T]) FieldDefinitions() attrs.Definitions

func (*DataModelField[T]) FormField

func (e *DataModelField[T]) FormField() fields.Field

func (*DataModelField[T]) GetDefault

func (e *DataModelField[T]) GetDefault() interface{}

func (*DataModelField[T]) GetValue

func (e *DataModelField[T]) GetValue() interface{}

func (*DataModelField[T]) HelpText

func (e *DataModelField[T]) HelpText() string

func (*DataModelField[T]) Instance

func (e *DataModelField[T]) Instance() attrs.Definer

func (*DataModelField[T]) IsPrimary

func (e *DataModelField[T]) IsPrimary() bool

func (*DataModelField[T]) Label

func (e *DataModelField[T]) Label() string

func (*DataModelField[T]) Name

func (f *DataModelField[T]) Name() string

func (*DataModelField[T]) Rel

func (e *DataModelField[T]) Rel() attrs.Relation

func (*DataModelField[T]) Scan

func (e *DataModelField[T]) Scan(src interface{}) error

func (*DataModelField[T]) SetValue

func (e *DataModelField[T]) SetValue(v interface{}, force bool) error

func (*DataModelField[T]) Tag

func (e *DataModelField[T]) Tag(string) string

func (*DataModelField[T]) ToString

func (e *DataModelField[T]) ToString() string

func (*DataModelField[T]) Type

func (e *DataModelField[T]) Type() reflect.Type

func (*DataModelField[T]) TypeString

func (f *DataModelField[T]) TypeString() string

func (*DataModelField[T]) Validate

func (e *DataModelField[T]) Validate() error

func (*DataModelField[T]) Value

func (e *DataModelField[T]) Value() (driver.Value, error)

type DataModelFieldConfig

type DataModelFieldConfig struct {
	ResultType reflect.Type // Type of the result of the expression
	Ref        attrs.Field  // Reference to the field in the model
}

type EmbedOptions

type EmbedOptions struct {
	// AutoInit indicates whether the pointer to the model should be automatically initialized
	// If AutoInit is true, the model will be initialized to a new instance
	// If it is false, the model will be left as nil and no fields will be embedded.
	AutoInit bool

	// EmbedFields specifies which fields of the model should be embedded
	// If EmbedFields is nil, all fields of the model will be embedded.
	EmbedFields []any
}

type ExpressionField

type ExpressionField[T any] struct {
	*DataModelField[T]
	// contains filtered or unexported fields
}

func NewVirtualField

func NewVirtualField[T any](forModel attrs.Definer, dst any, name string, expr expr.Expression) *ExpressionField[T]

func (*ExpressionField[T]) Alias

func (f *ExpressionField[T]) Alias() string

func (*ExpressionField[T]) SQL

func (f *ExpressionField[T]) SQL(inf *expr.ExpressionInfo) (string, []any)

type FieldConfig

type FieldConfig struct {
	DataModelFieldConfig
	ScanTo            any
	Nullable          bool
	AllowEdit         bool
	IsProxy           bool
	ReverseName       string
	NoReverseRelation bool // If true, the field will not create a reverse relation in the model meta.
	ColumnName        string
	TargetField       string
	Through           attrs.Through
	Rel               attrs.Relation
}

type ForeignKeyField

type ForeignKeyField[T any] struct {
	*RelationField[T]
}

func NewForeignKeyField

func NewForeignKeyField[T any](forModel attrs.Definer, name string, conf *FieldConfig) *ForeignKeyField[T]

func (*ForeignKeyField[T]) AllowDBEdit

func (e *ForeignKeyField[T]) AllowDBEdit() bool

func (*ForeignKeyField[T]) AllowEdit

func (e *ForeignKeyField[T]) AllowEdit() bool

func (*ForeignKeyField[T]) ForSelectAll

func (m *ForeignKeyField[T]) ForSelectAll() bool

type ForeignKeyReverseField

type ForeignKeyReverseField[T any] struct {
	*RelationField[T]
}

func NewForeignKeyReverseField

func NewForeignKeyReverseField[T any](forModel attrs.Definer, name string, conf *FieldConfig) *ForeignKeyReverseField[T]

type GenericForeignKeyConfig

type GenericForeignKeyConfig struct {
	Nullable         bool
	Target           attrs.Definer
	RelPrimary       string
	ContentTypeField string
	TargetField      string
}

type GenericForeignKeyField

type GenericForeignKeyField interface {
	queries.TargetClauseField
	queries.SaveableDependantField
}

type GenericForeignKeyFieldDefiner

type GenericForeignKeyFieldDefiner interface {
	ContentTypeField() attrs.Field
	PrimaryField() attrs.Field
}

type ManyToManyField

type ManyToManyField[T any] struct {
	*RelationField[T]
}

func NewManyToManyField

func NewManyToManyField[T any](forModel attrs.Definer, name string, conf *FieldConfig) *ManyToManyField[T]

type OneToOneField

type OneToOneField[T any] struct {
	*RelationField[T]
}

func NewOneToOneField

func NewOneToOneField[T any](forModel attrs.Definer, name string, conf *FieldConfig) *OneToOneField[T]

type OneToOneReverseField

type OneToOneReverseField[T any] struct {
	*RelationField[T]
}

func NewOneToOneReverseField

func NewOneToOneReverseField[T any](forModel attrs.Definer, name string, conf *FieldConfig) *OneToOneReverseField[T]

type RelationField

type RelationField[T any] struct {
	*DataModelField[T]
	// contains filtered or unexported fields
}

func NewRelatedField

func NewRelatedField[T any](forModel attrs.Definer, name string, cnf *FieldConfig) *RelationField[T]

func (*RelationField[T]) AllowDBEdit

func (r *RelationField[T]) AllowDBEdit() bool

func (*RelationField[T]) AllowEdit

func (r *RelationField[T]) AllowEdit() bool

func (*RelationField[T]) AllowNull

func (m *RelationField[T]) AllowNull() bool

func (*RelationField[T]) AllowReverseRelation

func (r *RelationField[T]) AllowReverseRelation() bool

func (*RelationField[T]) Attrs

func (r *RelationField[T]) Attrs() map[string]any

func (*RelationField[T]) CanMigrate

func (r *RelationField[T]) CanMigrate() bool

func (*RelationField[T]) ColumnName

func (r *RelationField[T]) ColumnName() string

func (*RelationField[T]) ForSelectAll

func (m *RelationField[T]) ForSelectAll() bool

func (*RelationField[T]) GenerateTargetClause

func (*RelationField[T]) GetTargetField

func (r *RelationField[T]) GetTargetField() attrs.FieldDefinition

func (*RelationField[T]) IsProxy

func (r *RelationField[T]) IsProxy() bool

func (*RelationField[T]) IsReverse

func (r *RelationField[T]) IsReverse() bool

func (*RelationField[T]) Name

func (m *RelationField[T]) Name() string

func (*RelationField[T]) Rel

func (r *RelationField[T]) Rel() attrs.Relation

func (*RelationField[T]) RelatedName

func (r *RelationField[T]) RelatedName() string

func (*RelationField[T]) Save

func (r *RelationField[T]) Save(ctx context.Context) error

Jump to

Keyboard shortcuts

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