Documentation ¶
Index ¶
- Constants
- func Dsn(filename 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 User
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 { FileName string `toml:"FileName" json:"FileName"` // sqlite文件名 MaxOpenConn int `toml:"MaxOpenConn" json:"MaxOpenConn"` // 最大连接数 MaxIDleConn int `toml:"MaxIDleConn" json:"MaxIDleConn"` // 最大空闲连接数 ConnMaxLifeTime time.Duration `toml:"ConnMaxLifeTime" json:"ConnMaxLifeTime"` // 最大连接超时时间, 单位分钟 }
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
Click to show internal directories.
Click to hide internal directories.