Documentation ¶
Index ¶
- Constants
- Variables
- func FilterDeleted() func(db *gorm.DB) *gorm.DB
- func NewKidLogger(config *gLogger.Config) gLogger.Interface
- func Paginate(pageNum, pageSize int) func(db *gorm.DB) *gorm.DB
- func Search(wheres []*WhereWrapper) func(db *gorm.DB) *gorm.DB
- func SearchScope(wheres where.Wheres) func(db *gorm.DB) *gorm.DB
- func Where(wheres []*WhereWrapper) func(db *gorm.DB) *gorm.DB
- func Wheres(wheres where.Wheres) func(db *gorm.DB) *gorm.DB
- type AutoMigrate
- type KidLogger
- func (log *KidLogger) Error(ctx context.Context, msg string, data ...interface{})
- func (log *KidLogger) Info(ctx context.Context, msg string, data ...interface{})
- func (log *KidLogger) LogMode(level gLogger.LogLevel) gLogger.Interface
- func (log *KidLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (log *KidLogger) Warn(ctx context.Context, msg string, data ...interface{})
- type MySQL
- type Option
- func WithCloseFKCheck(closeFKCheck bool) Option
- func WithDb(dbName string) Option
- func WithHost(host string) Option
- func WithLogLevel(logLevel int) Option
- func WithMaxIdle(maxIdle int) Option
- func WithMaxLife(maxLife time.Duration) Option
- func WithMaxOpen(maxOpen int) Option
- func WithPassword(password string) Option
- func WithPort(port int) Option
- func WithUser(user string) Option
- type Options
- type Repository
- func (repo *Repository) Count(finder *finder.Finder) error
- func (repo *Repository) Create(creator *creator.Creator) error
- func (repo *Repository) Delete(deleter *deleter.Deleter) error
- func (repo *Repository) Exec(tx context.Context, sql string, args ...interface{}) error
- func (repo *Repository) ExecWithTx(tx context.Context, fn func(tx context.Context) error) error
- func (repo *Repository) Exist(finder *finder.Finder) bool
- func (repo *Repository) Find(finder *finder.Finder) error
- func (repo *Repository) GetDb(ctx context.Context) interface{}
- func (repo *Repository) GetOne(finder *finder.Finder) error
- func (repo *Repository) GetUniqueID(finder *finder.Finder, min, max, ignoreStart, ignoreEnd int64) int64
- func (repo *Repository) Provide(context.Context) interface{}
- func (repo *Repository) Raw(tx context.Context, sql string, args ...interface{}) error
- func (repo *Repository) Save(creator *creator.Creator) error
- func (repo *Repository) Transaction(txFunc func(context.Context) error) error
- func (repo *Repository) Update(updater *updater.Updater) error
- func (repo *Repository) WhetherTx(tx context.Context) bool
- type WhereWrapper
Constants ¶
View Source
const ( ConditionTypeLte = "<=" ConditionTypeLt = "<" ConditionTypeGte = ">=" ConditionTypeGt = ">" ConditionTypeEq = "=" ConditionTypeIn = "in" )
Variables ¶
View Source
var (
MissingUpdates = errors.New("更新内容为空")
)
Functions ¶
Types ¶
type AutoMigrate ¶
type AutoMigrate interface {
Models() []interface{}
}
type Option ¶
type Option func(*Options)
func WithCloseFKCheck ¶
func WithLogLevel ¶
func WithMaxIdle ¶
func WithMaxLife ¶
func WithMaxOpen ¶
func WithPassword ¶
type Repository ¶
type Repository struct {
DB *MySQL `inject:""`
}
func (*Repository) Exec ¶
func (repo *Repository) Exec(tx context.Context, sql string, args ...interface{}) error
func (*Repository) ExecWithTx ¶
func (*Repository) GetDb ¶
func (repo *Repository) GetDb(ctx context.Context) interface{}
func (*Repository) GetUniqueID ¶
func (repo *Repository) GetUniqueID(finder *finder.Finder, min, max, ignoreStart, ignoreEnd int64) int64
func (*Repository) Provide ¶
func (repo *Repository) Provide(context.Context) interface{}
func (*Repository) Raw ¶
func (repo *Repository) Raw(tx context.Context, sql string, args ...interface{}) error
func (*Repository) Transaction ¶
func (repo *Repository) Transaction(txFunc func(context.Context) error) error
type WhereWrapper ¶
func NewWhereWrapper ¶
func NewWhereWrapper(col string, condition string, val interface{}) *WhereWrapper
func Wrappers ¶
func Wrappers(conditions ...*WhereWrapper) []*WhereWrapper
Click to show internal directories.
Click to hide internal directories.