model

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 3 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareField

func CompareField(l, r Field) bool

func CompareModel

func CompareModel(l, r Model) bool

func CompareTag

func CompareTag(l, r Tag) bool

func CompareType

func CompareType(l, r Type) bool

func CompareValue

func CompareValue(l, r Value) bool

Types

type Cache

type Cache interface {
	Reset()

	Put(name string, info 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 {
	//@GetIndex Index
	GetIndex() int
	//@GetName Name
	GetName() string
	//@GetType Type
	GetType() Type
	//@GetTag Tag
	GetTag() Tag
	//@GetValue Value
	GetValue() Value
	//@SetValue 更新值
	SetValue(val Value) error
	//@IsPrimary 是否主键
	IsPrimary() bool
}

Field Field

type Fields

type Fields []Field

Fields field info collection

func (*Fields) Append

func (s *Fields) Append(fieldInfo 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 interface{}) error
	NotEqual(key string, val interface{}) error
	Below(key string, val interface{}) error
	Above(key string, val interface{}) error
	In(key string, val interface{}) error
	NotIn(key string, val interface{}) error
	Like(key string, val interface{}) error
	ValueMask(val interface{}) error
	Page(filter *util.Pagination)
	Sort(sorter *util.SortFilter)

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

Filter orm query filter

type FilterItem

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

FilterItem FilterItem

type Model

type Model interface {
	GetName() string
	GetPkgPath() string
	GetFields() Fields
	SetFieldValue(name string, val Value) error
	GetPrimaryField() Field
	GetField(name string) Field
	Interface(ptrValue bool) interface{}
	Copy() Model
	Dump() string
}

Model Model

type OprFunc

type OprFunc func(string, interface{}) string

type Sorter

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

Sorter sort Item

type Tag

type Tag interface {
	// Tag名称
	GetName() string
	// 是否是主键
	IsPrimaryKey() bool
	// 是否自增
	IsAutoIncrement() bool
}

Tag Tag

type Type

type Type interface {
	// @GetName 名称
	GetName() string
	// @GetValue 值
	GetValue() int
	// @GetPkgPath pkgPath
	GetPkgPath() string
	// @IsPtrType 是否指针类型
	IsPtrType() bool
	// @Interface 实例化一个类型对应的数据值
	Interface() (Value, error)
	// Elem 获取要素类型(如果非slice,则返回的是本身,如果是slice,则返回slice的elem类型)
	Elem() Type
	// @IsBasic 判断是否基础类型(不是struct,也不是slice struct)
	IsBasic() bool
}

Type Type

type Value

type Value interface {
	// 是否为nil
	IsNil() bool
	// 设置值
	Set(val reflect.Value) error
	// 获取值
	Get() reflect.Value
	// 获取指针
	Addr() Value
	// 判断值是否是基础类型
	IsBasic() bool
}

Value Value

Jump to

Keyboard shortcuts

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