structspec

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldSpec

type FieldSpec struct {
	Tag              string // tag
	Name             string // 字段名
	I                int    // 位置
	Index            []int
	Column           string // 对应数据库字段名
	Type             string // 表字段类型,bool、string、int、int8、int16、int32、int64、uint、uint8、uint16、uint32、uint64、float、float64、blob(bytes)、enum、json、date、datetime
	OmitEmpty        bool   // 忽略零值
	OmitInsertEmpty  bool   // INSERT 时忽略零值
	OmitReplaceEmpty bool   // REPLACE 时忽略零值
	OmitUpdateEmpty  bool   // UPDATE 时忽略零值
	OnCreateTime     bool   // INSERT/REPLACE 时初始化为当前时间,具体格式根据 Type 决定,如果是数字类型包括 int、int32、int64 等,则是时间戳,否则就是 time.Time 类型
	OnUpdateTime     bool   // 数据变更时修改为当前时间,具体格式根据 Type 决定,这里我推荐数据库自带的时间戳更新功能。
}

FieldSpec body 标签解析结果

type StructSpec

type StructSpec struct {
	M  map[string]*FieldSpec
	Cm map[string]*FieldSpec
	Fs []*FieldSpec
}

func GetStructSpec

func GetStructSpec(tagName string, t reflect.Type) *StructSpec

GetStructSpec get structure tag info

func (*StructSpec) ColumnSpec

func (ss *StructSpec) ColumnSpec(name string) *FieldSpec

func (*StructSpec) FieldSpec

func (ss *StructSpec) FieldSpec(name string) *FieldSpec

Jump to

Keyboard shortcuts

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