model

package
v1.3.103 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 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 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
}

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

type Value

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

Value Value

type ValueDeclare added in v1.3.28

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

func (ValueDeclare) String added in v1.3.28

func (s ValueDeclare) String() string

type ViewDeclare added in v1.3.90

type ViewDeclare int

Jump to

Keyboard shortcuts

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