entity

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func JSONDefaultValue

func JSONDefaultValue[T any](val string) T

func JSONDefaultValueWithError

func JSONDefaultValueWithError[T any](val string) (T, error)

func ValidateEmail

func ValidateEmail(val string) error

func ValidateJSONDefaultValue

func ValidateJSONDefaultValue(val string) error

func ValidatePhone

func ValidatePhone(val string) error

Types

type CreateEdgeInput

type CreateEdgeInput struct {
	Caption          string
	RelatedEntity    *EntityConnectInput
	Required         *bool
	RelationType     RelationType
	Private          *bool
	BelongsToCaption *string
	Type             *string
	Ref              string
}

type CreateEntityInput

type CreateEntityInput struct {
	Caption      string
	DisplayField FieldWhereUniqueInput
	Fields       *CreateManyFieldsInput
	Edges        *CreateManyEdgesInput
	Lifecycle    *LifecycleInput
}

type CreateFieldInput

type CreateFieldInput struct {
	Caption        string
	Type           string
	Required       *bool
	Unique         *bool
	DefaultValue   *string
	Min            *string
	Max            *string
	Private        *bool
	AcceptedValues []string
}

type CreateManyEdgesInput

type CreateManyEdgesInput struct {
	Create []*CreateEdgeInput
}

type CreateManyFieldsInput

type CreateManyFieldsInput struct {
	Create []*CreateFieldInput
}

type Edge

type Edge struct {
	Name             string
	EntName          string
	Caption          string
	Type             string
	BelongsToCaption *string
	Required         *bool
	RelationType     RelationType
	Private          *bool
	Ref              string
}

func (*Edge) ApplyUpdateInput

func (e *Edge) ApplyUpdateInput(data UpdateEdgeInput)

func (Edge) Equals

func (f Edge) Equals(uniqueInput EdgeWhereUniqueInput) bool

func (Edge) Validate

func (e Edge) Validate() error

type EdgeWhereUniqueInput

type EdgeWhereUniqueInput struct {
	Name    *string
	Caption *string
}

type Entity

type Entity struct {
	Name             string
	EntName          string
	Caption          string
	Owner            EntityOwner
	DisplayFieldName string
	EntityState      State
}

func (*Entity) ApplyUpdateInput

func (e *Entity) ApplyUpdateInput(data UpdateEntityInput)

func (Entity) Equals

func (f Entity) Equals(uniqueInput EntityWhereUniqueInput) bool

func (Entity) Validate

func (f Entity) Validate() error

type EntityConnectInput

type EntityConnectInput struct {
	Connect EntityWhereUniqueInput
}

type EntityOwner

type EntityOwner string
const (
	EntityOwnerAdmin EntityOwner = "Admin"
	EntityOwnerUser  EntityOwner = "User"
)

func (EntityOwner) IsValid

func (e EntityOwner) IsValid() bool

func (EntityOwner) MarshalGQL

func (e EntityOwner) MarshalGQL(w io.Writer)

func (EntityOwner) String

func (e EntityOwner) String() string

func (*EntityOwner) UnmarshalGQL

func (e *EntityOwner) UnmarshalGQL(v interface{}) error

type EntityState added in v0.1.9

type EntityState string
const (
	EntityStateDraft     EntityState = "DRAFT"
	EntityStatePublished EntityState = "PUBLISHED"
	EntityStateArchived  EntityState = "ARCHIVED"
)

func (EntityState) IsValid added in v0.1.9

func (e EntityState) IsValid() bool

func (EntityState) MarshalGQL added in v0.1.9

func (e EntityState) MarshalGQL(w io.Writer)

func (EntityState) MarshalJSON added in v0.1.9

func (e EntityState) MarshalJSON() ([]byte, error)

func (EntityState) String added in v0.1.9

func (e EntityState) String() string

func (*EntityState) UnmarshalGQL added in v0.1.9

func (e *EntityState) UnmarshalGQL(v any) error

func (*EntityState) UnmarshalJSON added in v0.1.9

func (e *EntityState) UnmarshalJSON(b []byte) error

func (EntityState) Values added in v0.1.9

func (EntityState) Values() (kinds []string)

type EntityWhereUniqueInput

type EntityWhereUniqueInput struct {
	Name    *string
	Caption *string
	EntName *string
}

type Field

type Field struct {
	Name           string
	EntName        string
	Caption        string
	Type           string
	Required       *bool
	Unique         *bool
	DefaultValue   *string
	Min            *string
	Max            *string
	Private        *bool
	Nillable       bool
	UpdateDefault  bool
	AcceptedValues []string
}

func (*Field) ApplyUpdateInput

func (f *Field) ApplyUpdateInput(data UpdateFieldInput)

func (Field) Equals

func (f Field) Equals(uniqueInput FieldWhereUniqueInput) bool

func (Field) Validate

func (f Field) Validate() error

type FieldType

type FieldType string
const (
	FieldTypeID             FieldType = "ID"
	FieldTypeShortText      FieldType = "ShortText"
	FieldTypeLongText       FieldType = "LongText"
	FieldTypeRichText       FieldType = "RichText"
	FieldTypeFileContent    FieldType = "FileContent"
	FieldTypeEmail          FieldType = "Email"
	FieldTypeInteger        FieldType = "Integer"
	FieldTypeDecimal        FieldType = "Decimal"
	FieldTypeFloat          FieldType = "Float"
	FieldTypeBoolean        FieldType = "Boolean"
	FieldTypeSingleChoice   FieldType = "SingleChoice"
	FieldTypeMultipleChoice FieldType = "MultipleChoice"
	FieldTypeDateTime       FieldType = "DateTime"
	FieldTypeDate           FieldType = "Date"
	FieldTypeTime           FieldType = "Time"
	FieldTypeJson           FieldType = "Json"
	FieldTypeEnum           FieldType = "Enum"
	FieldTypeEnums          FieldType = "Enums"
)

type FieldWhereUniqueInput

type FieldWhereUniqueInput struct {
	Name    *string
	Caption *string
}

type LifecycleInput added in v0.1.9

type LifecycleInput struct {
	Enabled bool
	Default *EntityState
}

type LifecycleStateGetter added in v0.1.9

type LifecycleStateGetter interface {
	GetLifecycleState() EntityState
}

LifecycleStateGetter is implemented by generated ent models that have entity state (lifecycle) enabled. Used by hooks to check lifecycle state without reflection.

type RelationType

type RelationType string
const (
	RelationTypeOne  RelationType = "One"
	RelationTypeMany RelationType = "Many"
	RelationTypeO2O  RelationType = "OneToOne"
	RelationTypeO2M  RelationType = "OneToMany"
	RelationTypeM2O  RelationType = "ManyToOne"
	RelationTypeM2M  RelationType = "ManyToMany"
)

func (RelationType) IsValid

func (e RelationType) IsValid() bool

func (RelationType) MarshalGQL

func (e RelationType) MarshalGQL(w io.Writer)

func (RelationType) String

func (e RelationType) String() string

func (*RelationType) UnmarshalGQL

func (e *RelationType) UnmarshalGQL(v interface{}) error

func (RelationType) VariableName

func (e RelationType) VariableName() string

type State added in v0.1.9

type State struct {
	Enabled bool
	Default EntityState
}

type UpdateEdgeInput

type UpdateEdgeInput struct {
	Caption  *string
	Required *bool
	Private  *bool
}

type UpdateEntityInput

type UpdateEntityInput struct {
	Caption      *string
	DisplayField *FieldWhereUniqueInput
	Fields       *UpdateManyFieldsInput
	Edges        *UpdateManyEdgesInput
	Lifecycle    *LifecycleInput
}

type UpdateFieldInput

type UpdateFieldInput struct {
	Caption        *string  `json:"caption"`
	Required       *bool    `json:"required"`
	Unique         *bool    `json:"unique"`
	DefaultValue   *string  `json:"defaultValue"`
	Min            *string  `json:"min"`
	Max            *string  `json:"max"`
	Private        *bool    `json:"private"`
	AcceptedValues []string `json:"acceptedValues"`
}

type UpdateManyEdgesInput

type UpdateManyEdgesInput struct {
	Create []*CreateEdgeInput      `json:"create"`
	Update []*UpdateOneEdgeInput   `json:"update"`
	Delete []*EdgeWhereUniqueInput `json:"delete"`
}

type UpdateManyFieldsInput

type UpdateManyFieldsInput struct {
	Create []*CreateFieldInput      `json:"create"`
	Update []*UpdateOneFieldInput   `json:"update"`
	Delete []*FieldWhereUniqueInput `json:"delete"`
}

type UpdateOneEdgeInput

type UpdateOneEdgeInput struct {
	Where EdgeWhereUniqueInput
	Data  UpdateEdgeInput
}

type UpdateOneFieldInput

type UpdateOneFieldInput struct {
	Where FieldWhereUniqueInput
	Data  UpdateFieldInput
}

Jump to

Keyboard shortcuts

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