entity

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 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 NeedEdgeRead

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

Types

type Edge

type Edge struct {
	Name       string
	EntityName string
	Entity     *Entity
	Type       EdgeType
	Fields     []Field
	Inverse    bool
	ToOne      bool
	WithRead   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
	Config         *annotations.EntityConfig
}

func (Entity) GetIDField

func (e Entity) GetIDField() Field

type Field

type Field struct {
	Name       string
	Required   bool
	Immutable  bool
	AutoUpdate 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) 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
}

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
	IsPointer bool
}

Jump to

Keyboard shortcuts

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