Documentation
¶
Index ¶
- func Init(cfg *Config) (err error)
- type ColumnFilter
- type Config
- type DbTable
- func (t DbTable) AutoMigrate(dst interface{}) error
- func (t DbTable) Count(filter []ColumnFilter) (int, error)
- func (t DbTable) DB() *gorm.DB
- func (t DbTable) ExecSQL(sql string, result interface{}, args ...interface{}) error
- func (t DbTable) FirstOrCreate(filter, result interface{}) error
- func (t DbTable) FirstOrCreateWithNot(filter, notFilter, result interface{}) error
- func (t DbTable) GetRecord(filter, result interface{}) error
- func (t DbTable) GetRecords(filter []ColumnFilter, result interface{}, p Pagination, sort []SortByColumn) (err error)
- func (t DbTable) Insert(result interface{}) error
- func (t DbTable) IsRowExists(err error) bool
- func (t DbTable) IsRowNotFound(err error) bool
- func (t DbTable) UpdateRecord(filter, update interface{}) (err error)
- type Pagination
- type SortByColumn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ColumnFilter ¶
type ColumnFilter struct {
// contains filtered or unexported fields
}
func NewEqualFilter ¶
func NewEqualFilter(column string, value interface{}) ColumnFilter
func NewGreaterFilter ¶
func NewGreaterFilter(column string, value interface{}) ColumnFilter
func NewInFilter ¶
func NewInFilter(column string, value interface{}) ColumnFilter
func NewLikeFilter ¶
func NewLikeFilter(column string, value string) ColumnFilter
type Config ¶
type Config struct {
Host string `json:"host" required:"true"`
User string `json:"user" required:"true"`
Pwd string `json:"pwd" required:"true"`
Name string `json:"name" required:"true"`
Port int `json:"port" required:"true"`
Life int `json:"life" required:"true"`
MaxConn int `json:"max_conn" required:"true"`
MaxIdle int `json:"max_idle" required:"true"`
}
Config DbLife: the unit is minute
func (*Config) SetDefault ¶
func (cfg *Config) SetDefault()
type DbTable ¶
type DbTable struct {
// contains filtered or unexported fields
}
func NewDBTable ¶
func (DbTable) AutoMigrate ¶
func (DbTable) FirstOrCreate ¶
func (DbTable) FirstOrCreateWithNot ¶
func (DbTable) GetRecords ¶
func (t DbTable) GetRecords( filter []ColumnFilter, result interface{}, p Pagination, sort []SortByColumn, ) (err error)
func (DbTable) IsRowExists ¶
func (DbTable) IsRowNotFound ¶
func (DbTable) UpdateRecord ¶
type Pagination ¶
type SortByColumn ¶
Click to show internal directories.
Click to hide internal directories.