fields

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataModelField

type DataModelField[T any] struct {
	// model is the model that this field belongs to
	Model any

	// dataModel is the model that contains the data for this field
	//
	// it should be embedded in the attrs.Definer type which this virtual field is for
	DataModel any
	// contains filtered or unexported fields
}

func NewDataModelField

func NewDataModelField[T any](forModel any, dst any, name string) *DataModelField[T]

func (*DataModelField[T]) AllowBlank

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

func (*DataModelField[T]) AllowEdit

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

func (*DataModelField[T]) AllowNull

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

func (*DataModelField[T]) AnnotateValue

func (e *DataModelField[T]) AnnotateValue(v any) error

func (*DataModelField[T]) Attrs

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

func (*DataModelField[T]) ColumnName

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

no real column, special case for virtual fields

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{}, _ 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]) Validate

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

func (*DataModelField[T]) Value

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

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 ForeignKeyField

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

func NewForeignKeyField

func NewForeignKeyField[T any](forModel attrs.Definer, dst any, name string, reverseName string, columnName string, rel attrs.Relation) *ForeignKeyField[T]

type ForeignKeyReverseField

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

func NewForeignKeyReverseField

func NewForeignKeyReverseField[T any](forModel attrs.Definer, dst any, name string, reverseName string, columnName string, rel attrs.Relation) *ForeignKeyReverseField[T]

type ManyToManyField

type ManyToManyField[T attrs.Definer] struct {
	*RelationField[T]
}

func NewManyToManyField

func NewManyToManyField[T attrs.Definer](forModel attrs.Definer, dst any, name string, reverseName string, columnName string, rel attrs.Relation) *ManyToManyField[T]

type MultipleRelation

type MultipleRelation struct {
	// contains filtered or unexported fields
}

func (*MultipleRelation) Add

func (m *MultipleRelation) Add(obj attrs.Definer) error

func (*MultipleRelation) All

func (m *MultipleRelation) All() []attrs.Definer

func (*MultipleRelation) Clear

func (m *MultipleRelation) Clear() error

func (*MultipleRelation) Get

func (m *MultipleRelation) Get(pkOrObj any) (attrs.Definer, bool)

func (*MultipleRelation) Remove

func (m *MultipleRelation) Remove(obj attrs.Definer) error

func (*MultipleRelation) Set

func (m *MultipleRelation) Set(objs []attrs.Definer) error

type MultipleRelationField

type MultipleRelationField struct {
	*RelationField[[]attrs.Definer]
	// contains filtered or unexported fields
}

func NewMultipleRelatedField

func NewMultipleRelatedField(forModel attrs.Definer, name string, reverseName string, columnName string, rel attrs.Relation) *MultipleRelationField

func (*MultipleRelationField) GetValue

func (f *MultipleRelationField) GetValue() any

func (*MultipleRelationField) Objects

func (*MultipleRelationField) SetValue

func (f *MultipleRelationField) SetValue(value any, force bool) error

type OneToOneField

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

func NewOneToOneField

func NewOneToOneField[T any](forModel attrs.Definer, dst any, name string, reverseName string, columnName string, rel attrs.Relation) *OneToOneField[T]

type OneToOneReverseField

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

func NewOneToOneReverseField

func NewOneToOneReverseField[T any](forModel attrs.Definer, dst any, name string, reverseName string, columnName string, rel attrs.Relation) *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, dst any, name string, reverseName string, columnName string, rel attrs.Relation) *RelationField[T]

func (*RelationField[T]) Attrs

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

func (*RelationField[T]) ColumnName

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

func (*RelationField[T]) ForSelectAll

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

func (*RelationField[T]) GetTargetField

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

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

Jump to

Keyboard shortcuts

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