entity

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EdgeO2O = iota
	EdgeO2M
	EdgeM2O
	EdgeM2M
)
View Source
const ImportsEntities = "entities"

Variables

This section is empty.

Functions

func NeedEdgeCreate added in v0.0.30

func NeedEdgeCreate(sch *Schema, cfg *annotations.EdgeConfig) bool

func NeedEdgeDelete added in v0.0.30

func NeedEdgeDelete(sch *Schema, cfg *annotations.EdgeConfig) bool

func NeedEdgeRead

func NeedEdgeRead(sch *Schema, cfg *annotations.EdgeConfig) bool

func NeedEdgeUpdate added in v0.0.30

func NeedEdgeUpdate(sch *Schema, cfg *annotations.EdgeConfig) bool

Types

type Edge

type Edge struct {
	Name       string
	RefName    string
	FieldName  string
	EntityName string
	Order      int
	Entity     *Entity
	Type       EdgeType
	Fields     []Field
	Inverse    bool
	ToOne      bool
	WithRead   bool
	WithCreate bool
	WithUpdate bool
	WithDelete bool
}

func (*Edge) ToMany added in v0.0.30

func (e *Edge) ToMany() bool

type EdgeType

type EdgeType int

type Entity

type Entity struct {
	Model          any
	Path           string
	Name           string
	NeedFlat       bool
	Fields         []Field
	Edges          []*Edge
	HasReadEdges   bool
	HasCreateEdges bool
	HasUpdateEdges bool
	HasDeleteEdges bool
	Config         *annotations.EntityConfig
}

func (Entity) GetIDField

func (e Entity) GetIDField() Field

type Field

type Field struct {
	Name       string
	Required   bool
	Optional   bool
	Immutable  bool
	AutoUpdate bool
	Edge       bool
	Openapi    Openapi
	Phantom    bool
	RType      reflect.Type
	Type       TypeInfo
	Enum       []any
	Config     *annotations.FieldConfig
	Order      int
}

type FieldType

type FieldType uint8
const (
	TypeInvalid FieldType = iota
	TypeBool
	TypeTime
	TypeDate
	TypeDateTime
	TypeJSON
	TypeUUID
	TypeBytes
	TypeEnum
	TypeString
	TypeOther
	TypeInt8
	TypeInt16
	TypeInt32
	TypeInt
	TypeInt64
	TypeUint8
	TypeUint16
	TypeUint32
	TypeUint
	TypeUint64
	TypeFloat32
	TypeFloat64
)

func (FieldType) CanRange added in v0.0.30

func (t FieldType) CanRange() bool

func (FieldType) Name

func (t FieldType) Name() string

func (FieldType) OApiTypeName

func (f FieldType) OApiTypeName() string

func (FieldType) ProtoTypeName

func (f FieldType) ProtoTypeName() string

func (FieldType) TemplateName

func (t FieldType) TemplateName() string

type Openapi

type Openapi struct {
	Type      string
	Format    string
	HasFormat bool
}

type Parser

type Parser interface {
	Parse([]lib.PreEntity, *Schema)
}

type Schema

type Schema struct {
	Pkg          string
	EntPath      string
	RootPkg      string
	Entities     []*Entity
	Edges        []*Edge
	Imports      map[string][]string
	Cfg          config.GenConfigItem
	WD           string
	ProtoImports []string
}

func (*Schema) AddImport

func (sch *Schema) AddImport(t, imprt string)

type TypeInfo

type TypeInfo struct {
	Type FieldType
	Name string
	// import name for composite e.g. uuid.UUID
	Import       string
	ProtoImport  *string
	ProtoPointer bool
	IsPointer    bool
}

Jump to

Keyboard shortcuts

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