model

package
v1.3.171 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 4 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// TypeBooleanValue bool
	TypeBooleanValue = iota + 100
	// TypeBitValue int8
	TypeBitValue
	// TypeSmallIntegerValue int16
	TypeSmallIntegerValue
	// TypeInteger32Value int32
	TypeInteger32Value
	// TypeIntegerValue int
	TypeIntegerValue
	// TypeBigIntegerValue int64
	TypeBigIntegerValue
	// TypePositiveBitValue uint8
	TypePositiveBitValue
	// TypePositiveSmallIntegerValue uint16
	TypePositiveSmallIntegerValue
	// TypePositiveInteger32Value uint32
	TypePositiveInteger32Value
	// TypePositiveIntegerValue uint
	TypePositiveIntegerValue
	// TypePositiveBigIntegerValue uint64
	TypePositiveBigIntegerValue
	// TypeFloatValue float32
	TypeFloatValue
	// TypeDoubleValue float64
	TypeDoubleValue
	// TypeStringValue string
	TypeStringValue
	// TypeDateTimeValue time.Time
	TypeDateTimeValue
	// TypeStructValue struct
	TypeStructValue
	// TypeSliceValue slice
	TypeSliceValue
	// TypeMapValue map
	TypeMapValue = 500
)

Define the Type enum

View Source
const (
	OriginView = 0
	FullView   = 1
	LiteView   = 2
)
View Source
const (
	EqualOpr    = iota // =
	NotEqualOpr        // !=
	BelowOpr           // <
	AboveOpr           // >
	InOpr              // in
	NotInOpr           // !in
	LikeOpr            // like
)

Variables

This section is empty.

Functions

func CompareField

func CompareField(l, r Field) bool

func CompareModel

func CompareModel(l, r Model) bool

func CompareSpec added in v1.3.23

func CompareSpec(l, r Spec) bool

func CompareType

func CompareType(l, r Type) bool

func CompareValue

func CompareValue(l, r Value) bool

func IsAutoIncrement added in v1.3.28

func IsAutoIncrement(val ValueDeclare) bool

func IsBasicSlice added in v1.3.28

func IsBasicSlice(tType Type) bool

func IsBasicType added in v1.3.28

func IsBasicType(typeValue TypeDeclare) bool

func IsCustomer added in v1.3.28

func IsCustomer(val ValueDeclare) bool

func IsDateTime added in v1.3.28

func IsDateTime(val ValueDeclare) bool

func IsDateTimeType added in v1.3.28

func IsDateTimeType(typeValue TypeDeclare) bool

func IsMapType added in v1.3.28

func IsMapType(typeVal TypeDeclare) bool

func IsSliceType added in v1.3.28

func IsSliceType(typeValue TypeDeclare) bool

func IsSnowFlake added in v1.3.28

func IsSnowFlake(val ValueDeclare) bool

func IsStructSlice added in v1.3.28

func IsStructSlice(tType Type) bool

func IsStructType added in v1.3.28

func IsStructType(typeValue TypeDeclare) bool

func IsUUID added in v1.3.28

func IsUUID(val ValueDeclare) bool

Types

type Cache

type Cache interface {
	Reset()

	Put(name string, vModel Model)

	Fetch(name string) Model

	Remove(name string)
}

Cache Model Cache

func NewCache

func NewCache() Cache

NewCache new modelInfo cache

type Field

type Field interface {
	GetName() string
	GetDescription() string
	GetType() Type
	GetSpec() Spec
	GetValue() Value
	SetValue(val Value)
	IsPrimaryKey() bool
	IsBasic() bool
	IsStruct() bool
	IsSlice() bool
	IsPtrType() bool
}

type Fields

type Fields []Field

Fields field info collection

func (*Fields) Append

func (s *Fields) Append(vField Field) bool

Append Append

func (*Fields) GetPrimaryField

func (s *Fields) GetPrimaryField() Field

GetPrimaryField get primary key field

type Filter

type Filter interface {
	Equal(key string, val any) *cd.Result
	NotEqual(key string, val any) *cd.Result
	Below(key string, val any) *cd.Result
	Above(key string, val any) *cd.Result
	In(key string, val any) *cd.Result
	NotIn(key string, val any) *cd.Result
	Like(key string, val any) *cd.Result
	Page(page *util.Pagination)
	Sort(sorter *util.SortFilter)
	ValueMask(val any) *cd.Result

	GetFilterItem(key string) FilterItem
	Pagination() (limit, offset int, paging bool)
	Sorter() Sorter
	MaskModel() Model
}

Filter orm query filter

type FilterItem

type FilterItem interface {
	OprCode() OprCode
	OprValue() Value
}

FilterItem FilterItem

type Model

type Model interface {
	GetName() string
	GetPkgPath() string
	GetDescription() string
	GetPkgKey() string
	GetFields() Fields
	SetFieldValue(name string, val Value)
	SetPrimaryFieldValue(val Value)
	GetPrimaryField() Field
	GetField(name string) Field
	Interface(ptrValue bool, viewSpec ViewDeclare) any
	Copy(reset bool) Model
	Dump() string
}

type OprCode added in v1.3.4

type OprCode int

type RawVal added in v1.3.147

type RawVal interface {
	Value() any
}

func NewRawVal added in v1.3.147

func NewRawVal(val any) RawVal

type Sorter

type Sorter interface {
	Name() string
	AscSort() bool
}

Sorter sort Item

type Spec added in v1.3.23

type Spec interface {
	IsPrimaryKey() bool
	GetValueDeclare() ValueDeclare
	EnableView(ViewDeclare) bool
	GetDefaultValue() RawVal
}

type Type

type Type interface {
	GetName() string
	GetPkgPath() string
	GetDescription() string
	GetValue() TypeDeclare
	GetPkgKey() string
	IsPtrType() bool
	Interface(initVal any) (Value, *cd.Result)
	// Elem 获取要素类型(如果非slice,则返回的是本身,如果是slice,则返回slice的elem类型)
	Elem() Type
	IsBasic() bool
	IsStruct() bool
	IsSlice() bool
}

type TypeDeclare added in v1.3.28

type TypeDeclare int

func (TypeDeclare) IsBasicType added in v1.3.113

func (s TypeDeclare) IsBasicType() bool

func (TypeDeclare) IsDateTimeType added in v1.3.113

func (s TypeDeclare) IsDateTimeType() bool

func (TypeDeclare) IsMapType added in v1.3.113

func (s TypeDeclare) IsMapType() bool

func (TypeDeclare) IsSliceType added in v1.3.113

func (s TypeDeclare) IsSliceType() bool

func (TypeDeclare) IsStructType added in v1.3.113

func (s TypeDeclare) IsStructType() bool

func (TypeDeclare) String added in v1.3.113

func (s TypeDeclare) String() string

type Value

type Value interface {
	IsValid() bool
	IsZero() bool
	Set(val any)
	Get() any
	Addr() Value
	Interface() RawVal
	IsBasic() bool
}

Value Value

type ValueDeclare added in v1.3.28

type ValueDeclare int
const (
	Customer ValueDeclare = iota
	AutoIncrement
	UUID
	SnowFlake
	DateTime
)

func (ValueDeclare) IsAutoIncrement added in v1.3.113

func (s ValueDeclare) IsAutoIncrement() bool

func (ValueDeclare) IsCustomer added in v1.3.113

func (s ValueDeclare) IsCustomer() bool

func (ValueDeclare) IsDaeTime added in v1.3.113

func (s ValueDeclare) IsDaeTime() bool

func (ValueDeclare) IsSnowFlake added in v1.3.113

func (s ValueDeclare) IsSnowFlake() bool

func (ValueDeclare) IsUUID added in v1.3.113

func (s ValueDeclare) IsUUID() bool

func (ValueDeclare) String added in v1.3.28

func (s ValueDeclare) String() string

type ViewDeclare added in v1.3.90

type ViewDeclare int

func (ViewDeclare) String added in v1.3.113

func (s ViewDeclare) String() string

Jump to

Keyboard shortcuts

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