Documentation ¶
Index ¶
- Constants
- func Dsn(user, pass, addr, dbName string) string
- type DB
- type Info
- type Predicate
- type QueryBuilder
- func (qb *QueryBuilder) BuildQuery(db *gorm.DB) *gorm.DB
- func (qb *QueryBuilder) Count(db *gorm.DB) (int64, error)
- func (qb *QueryBuilder) Create(db *gorm.DB, model interface{}) (rowsAffected int64, err error)
- func (qb *QueryBuilder) Delete(db *gorm.DB) (rowsAffected int64, err error)
- func (qb *QueryBuilder) Exist(db *gorm.DB) (bool, error)
- func (qb *QueryBuilder) First(db *gorm.DB, ret interface{}) error
- func (qb *QueryBuilder) Get(db *gorm.DB, ret interface{}) error
- func (qb *QueryBuilder) GroupBy(field string) *QueryBuilder
- func (qb *QueryBuilder) Limit(limit int) *QueryBuilder
- func (qb *QueryBuilder) List(db *gorm.DB, ret interface{}) error
- func (qb *QueryBuilder) Offset(offset int) *QueryBuilder
- func (qb *QueryBuilder) OrderBy(field string, sortType pagex.SortType) *QueryBuilder
- func (qb *QueryBuilder) Page(db *gorm.DB, val interface{}, param *pagex.Params) (*pagex.Result, error)
- func (qb *QueryBuilder) SetModel(model interface{})
- func (qb *QueryBuilder) Transaction(db *gorm.DB, fc func(tx *gorm.DB) error, opts ...*sql.TxOptions) (err error)
- func (qb *QueryBuilder) Updates(db *gorm.DB, m map[string]interface{}) (rowsAffected int64, err error)
- func (qb *QueryBuilder) Where(p Predicate, field string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) WhereIn(field string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) WhereNotIn(field string, value interface{}) *QueryBuilder
- type Repo
- type TracePlugin
Constants ¶
View Source
const ( EqualPredicate = Predicate("=") NotEqualPredicate = Predicate("<>") GreaterThanPredicate = Predicate(">") GreaterThanOrEqualPredicate = Predicate(">=") SmallerThanPredicate = Predicate("<") SmallerThanOrEqualPredicate = Predicate("<=") LikePredicate = Predicate("LIKE") )
View Source
const ( CreateErrStr = "create error" UpdatesErrStr = "updates error" DeleteErrStr = "delete error" )
err 常量
View Source
const ( DescStr = "DESC" AscStr = "ASC" InStr = "IN" NotInStr = "NOT IN" )
查询常量
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Info ¶
type Info struct { Read []struct { Addr string `toml:"Addr" json:"Addr"` User string `toml:"User" json:"User"` Pass string `toml:"Pass" json:"Pass"` Name string `toml:"Name" json:"Name"` } `toml:"Read" json:"Read"` Write []struct { Addr string `toml:"Addr" json:"Addr"` User string `toml:"User" json:"User"` Pass string `toml:"Pass" json:"Pass"` Name string `toml:"Name" json:"Name"` } `toml:"Write" json:"Write"` Base struct { MaxOpenConn int `toml:"MaxOpenConn" json:"MaxOpenConn"` MaxIDleConn int `toml:"MaxIDleConn" json:"MaxIDleConn"` ConnMaxLifeTime time.Duration `toml:"ConnMaxLifeTime" json:"ConnMaxLifeTime"` // 最大连接超时时间单位分钟 } `toml:"Base"` }
type Predicate ¶
type Predicate string
Predicate is a string that acts as a condition in the where clause
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
func NewQueryBuilder ¶
func NewQueryBuilder(model interface{}, mustBeField ...string) *QueryBuilder
func (*QueryBuilder) BuildQuery ¶
func (qb *QueryBuilder) BuildQuery(db *gorm.DB) *gorm.DB
func (*QueryBuilder) Create ¶
func (qb *QueryBuilder) Create(db *gorm.DB, model interface{}) (rowsAffected int64, err error)
func (*QueryBuilder) Delete ¶
func (qb *QueryBuilder) Delete(db *gorm.DB) (rowsAffected int64, err error)
func (*QueryBuilder) GroupBy ¶
func (qb *QueryBuilder) GroupBy(field string) *QueryBuilder
func (*QueryBuilder) Limit ¶
func (qb *QueryBuilder) Limit(limit int) *QueryBuilder
func (*QueryBuilder) Offset ¶
func (qb *QueryBuilder) Offset(offset int) *QueryBuilder
func (*QueryBuilder) OrderBy ¶
func (qb *QueryBuilder) OrderBy(field string, sortType pagex.SortType) *QueryBuilder
func (*QueryBuilder) SetModel ¶
func (qb *QueryBuilder) SetModel(model interface{})
func (*QueryBuilder) Transaction ¶
func (*QueryBuilder) Where ¶
func (qb *QueryBuilder) Where(p Predicate, field string, value interface{}) *QueryBuilder
func (*QueryBuilder) WhereIn ¶
func (qb *QueryBuilder) WhereIn(field string, value interface{}) *QueryBuilder
func (*QueryBuilder) WhereNotIn ¶
func (qb *QueryBuilder) WhereNotIn(field string, value interface{}) *QueryBuilder
type TracePlugin ¶
type TracePlugin struct{}
func (*TracePlugin) Initialize ¶
func (op *TracePlugin) Initialize(db *gorm.DB) (err error)
func (*TracePlugin) Name ¶
func (op *TracePlugin) Name() string
Click to show internal directories.
Click to hide internal directories.