model

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 3 Imported by: 8

Documentation

Index

Constants

View Source
const (
	EqualOpr    = iota // =
	NotEqualOpr        // !=
	BelowOpr           // <
	AboveOpr           // >
	InOpr              // in
	NotInOpr           // not 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 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() int
	GetName() string
	GetType() Type
	GetTag() Tag
	GetValue() Value
	SetValue(val Value) error
	IsPrimary() bool
}

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
	Page(filter *util.Pagination)
	Sort(sorter *util.SortFilter)
	ValueMask(val interface{}) error

	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
	GetPkgKey() string
	GetFields() Fields
	SetFieldValue(name string, val Value) error
	GetPrimaryField() Field
	GetField(name string) Field
	Interface(ptrValue bool) interface{}
	Copy() 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 Tag

type Tag interface {
	GetName() string
	IsPrimaryKey() bool
	IsAutoIncrement() bool
}

type Type

type Type interface {
	GetName() string
	GetValue() int
	GetPkgPath() string
	GetPkgKey() string
	IsPtrType() bool
	Interface() Value
	// Elem 获取要素类型(如果非slice,则返回的是本身,如果是slice,则返回slice的elem类型)
	Elem() Type
	IsBasic() bool
}

type Value

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

Value Value

Jump to

Keyboard shortcuts

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