database

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrate added in v0.0.4

func AutoMigrate(models ...interface{})

AutoMigrate ...

func DB

func DB() *gorm.DB

获取数据库链接

func OpenDB

func OpenDB(dsn ResolverDSN, config *gorm.Config, maxIdleConnes, maxOpenConnes int) (err error)

func SqlNullString

func SqlNullString(value string) sql.NullString

Types

type GormModel

type GormModel struct {
	Id        int64 `gorm:"primaryKey;autoIncrement" json:"id" form:"id"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type OrderByCol

type OrderByCol struct {
	Column string // 排序字段
	Asc    bool   // 是否正序
}

排序信息

type ParamPair

type ParamPair struct {
	Query string        // 查询
	Args  []interface{} // 参数
}

type ResolverDSN

type ResolverDSN struct {
	Sources   []string `yaml:"Sources"`
	Replicas  []string `yaml:"Replicas"`
	Secondary []string `yaml:"Secondary"`
}

type SqlCnd

type SqlCnd struct {
	SelectCols []string           // 要查询的字段,如果为空,表示查询所有字段
	Params     []ParamPair        // 参数
	Orders     []OrderByCol       // 排序
	Paging     *pagination.Paging // 分页
}

func NewSqlCnd

func NewSqlCnd() *SqlCnd

func (*SqlCnd) Asc

func (s *SqlCnd) Asc(column string) *SqlCnd

func (*SqlCnd) Build

func (s *SqlCnd) Build(db *gorm.DB) *gorm.DB

func (*SqlCnd) Cols

func (s *SqlCnd) Cols(selectCols ...string) *SqlCnd

func (*SqlCnd) Count

func (s *SqlCnd) Count(db *gorm.DB, model interface{}) int64

func (*SqlCnd) Desc

func (s *SqlCnd) Desc(column string) *SqlCnd

func (*SqlCnd) Ending

func (s *SqlCnd) Ending(column string, str string) *SqlCnd

func (*SqlCnd) Eq

func (s *SqlCnd) Eq(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) Find

func (s *SqlCnd) Find(db *gorm.DB, out interface{})

func (*SqlCnd) FindOne

func (s *SqlCnd) FindOne(db *gorm.DB, out interface{}) error

func (*SqlCnd) Gt

func (s *SqlCnd) Gt(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) Gte

func (s *SqlCnd) Gte(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) In

func (s *SqlCnd) In(column string, params interface{}) *SqlCnd

func (*SqlCnd) Like

func (s *SqlCnd) Like(column string, str string) *SqlCnd

func (*SqlCnd) Limit

func (s *SqlCnd) Limit(limit int) *SqlCnd

func (*SqlCnd) Lt

func (s *SqlCnd) Lt(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) Lte

func (s *SqlCnd) Lte(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) NotEq

func (s *SqlCnd) NotEq(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) Page

func (s *SqlCnd) Page(page, limit int) *SqlCnd

func (*SqlCnd) Starting

func (s *SqlCnd) Starting(column string, str string) *SqlCnd

func (*SqlCnd) Where

func (s *SqlCnd) Where(query string, args ...interface{}) *SqlCnd

Jump to

Keyboard shortcuts

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