construct

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GuessStructTags

func GuessStructTags(ci *schema.ColumnInfo) string

根据数据库字段属性设置Struct tags

func GuessTypeName

func GuessTypeName(ci *schema.ColumnInfo) string

根据数据库字段类型猜测Go类型,适用于mysql或pgsql

func Paginate

func Paginate(query *gorm.DB, out interface{}, pageno, pagesize int) (total int, err error)

*

  • 翻页查询,out参数需要传引用
  • 使用方法 total, err := Paginate(query, &rows, pageno, pagesize)

Types

type FilterFunc

type FilterFunc = func(query *gorm.DB) *gorm.DB

*

  • 过滤查询
  • 使用方法 query = query.Scopes(filters ...FilterFunc)

type Model

type Model struct {
	ID uint `json:"id" gorm:"primary_key;not null;auto_increment"`
}

type SqlTag

type SqlTag struct {
	reflect.StructTag
	// contains filtered or unexported fields
}

StructTag named sql or gorm

func NewSqlTag

func NewSqlTag() *SqlTag

func (*SqlTag) Delete

func (st *SqlTag) Delete(key string)

Deletes a tag

func (*SqlTag) Get

func (st *SqlTag) Get(key string) (string, bool)

Returns a tag from the tag data

func (*SqlTag) ParseTag

func (st *SqlTag) ParseTag(tag reflect.StructTag)

func (*SqlTag) Set

func (st *SqlTag) Set(key, val string)

Sets a tag in the tag data map

func (*SqlTag) String

func (st *SqlTag) String(head string) string

转为字符串格式,头通常使用sql或gorm

Jump to

Keyboard shortcuts

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