construct

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 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

func GuessTypeName

func GuessTypeName(ci *schema.ColumnInfo) string

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(filter 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

Jump to

Keyboard shortcuts

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