Documentation ¶
Index ¶
- Constants
- Variables
- func AddModels(v ...interface{})
- func AutoDelete(db *gorm.DB, bus interface{})
- func BatchDeleteFromTop(db *gorm.DB, model interface{}, count int)
- func CreateIfNotExists(db *gorm.DB, bean interface{}, query interface{}, args ...interface{}) error
- func FindRecords[T any](val T, call func(tx *gorm.DB) *gorm.DB, args ...interface{}) (sliceResult []T, err error)
- func FindRecordsWithDB[T any](db *gorm.DB, val T, call func(tx *gorm.DB) *gorm.DB, args ...interface{}) (sliceResult []T, err error)
- func HDeleter(c *redis.Client, key string) func(fields ...string)
- func HScanCallback(c *redis.Client, key, match string, fn func(k, v string))
- func Md5(b []byte) string
- func ModelTableName(model interface{}) string
- func NewDBLoggerSilent() logger.Interface
- func NewDBLoggerWithLevel(level logger.LogLevel) logger.Interface
- func NewDBLoggerWithLevelOut(level logger.LogLevel, logName string) logger.Interface
- func NewPlugin(c Config) gorm.Plugin
- func ParseModel(model interface{}) (s *schema.Schema, err error)
- func SetModelBus(bus interface{})
- func ValueIDUint64(val util.Map) (id uint64, ok bool)
- type BaseModel
- type CCStore
- type CacheStore
- type Config
- type CreateClause
- type CurdParams
- type DBOption
- type FindByID
- type FindParams
- type FindResult
- type FreeStore
- type GormDB
- func (g *GormDB) CheckDBNil() (err error)
- func (g *GormDB) Close() (err error)
- func (g *GormDB) CreateDB()
- func (g *GormDB) DropDB()
- func (g *GormDB) GetFindModel(table string) (interface{}, error)
- func (g *GormDB) GetModel(table string) (interface{}, error)
- func (g *GormDB) Initialize(opt *DBOption) *GormDB
- func (g *GormDB) MigrateModels(v ...interface{})
- func (g *GormDB) ModelByTableName(tableName string) (model interface{}, err error)
- func (g *GormDB) ModelTableName(model interface{}) (name string)
- func (g *GormDB) Models() map[string]interface{}
- func (g *GormDB) Opt() *DBOption
- func (g *GormDB) RegModel(model interface{})
- func (g *GormDB) RegModelBus(bus interface{})
- func (g *GormDB) RegViewModel(model interface{})
- func (g *GormDB) SetOpt(opt *DBOption)
- func (g *GormDB) ViewModels() map[string]interface{}
- type ImplResultAfterFind
- type ItfModelInitializer
- type Pagination
- type PluginCacheStat
- type RedisOptions
- type RedisStore
- func (r *RedisStore) ClearAll()
- func (r *RedisStore) Del(key string)
- func (r *RedisStore) DropPrefix(prefix ...string)
- func (r *RedisStore) Get(key string) (data []byte, ok bool)
- func (r *RedisStore) GetKeyFieldOrNot(key string) (k, f string, y bool)
- func (r *RedisStore) ScanKeys(matchParam string) []string
- func (r *RedisStore) Set(key string, data []byte, ttl ...int64)
- func (r *RedisStore) StoreGC(prefix string)
- type RedisStoreOption
- type RedisV9
- type RedisValue
- type StoreGC
- type Time
- type UpdateClause
- type Version
- func (v *Version) CreateClauses(field *schema.Field) []clause.Interface
- func (v *Version) MarshalJSON() ([]byte, error)
- func (v *Version) Scan(value interface{}) error
- func (v *Version) UnmarshalJSON(bytes []byte) error
- func (v *Version) UpdateClauses(field *schema.Field) []clause.Interface
- func (v *Version) Value() (driver.Value, error)
Constants ¶
View Source
const (
NoCache = "no-cache"
)
Variables ¶
View Source
var ( DB = NewGormDB() ErrRecordExists = errors.New("record exists") )
View Source
var (
PCacheStat = new(PluginCacheStat)
)
View Source
var Rdb = new(RedisV9)
View Source
var SeparatorColon = ":"
Functions ¶
func AutoDelete ¶
func BatchDeleteFromTop ¶
BatchDeleteFromTop eachCount = 1000; count: count of delete rows , order by id asc
func CreateIfNotExists ¶
func FindRecords ¶ added in v1.0.0
func FindRecordsWithDB ¶ added in v1.0.0
func FindRecordsWithDB[T any](db *gorm.DB, val T, call func(tx *gorm.DB) *gorm.DB, args ...interface{}) (sliceResult []T, err error)
FindRecordsWithDB ...
func HScanCallback ¶
func ModelTableName ¶
func ModelTableName(model interface{}) string
func NewDBLoggerSilent ¶ added in v1.0.0
func NewDBLoggerWithLevel ¶ added in v0.0.2
func NewDBLoggerWithLevelOut ¶ added in v1.0.0
func ParseModel ¶
func SetModelBus ¶
func SetModelBus(bus interface{})
Types ¶
type BaseModel ¶ added in v1.0.0
type BaseModel struct { ID int `json:"id,omitempty" gorm:"primaryKey;autoIncrement:true;autoIncrementIncrement:1;"` CreatedAt *Time `json:"created_at,omitempty" gorm:"notnull;default:CURRENT_TIMESTAMP;"` UpdatedAt *Time `json:"updated_at,omitempty" gorm:"notnull;"` Version *Version `json:"version,omitempty" gorm:"notnull;default:1;comment:版本号;"` }
type CCStore ¶ added in v1.0.0
type CCStore struct {
// contains filtered or unexported fields
}
func GetCCacheStore ¶
func GetCCacheStore() *CCStore
func NewCCacheStore ¶ added in v1.0.0
func NewCCacheStore() *CCStore
func (*CCStore) DropPrefix ¶ added in v1.0.0
type CacheStore ¶
type Config ¶
type Config struct { Skip bool // TTL is the time to live in seconds, default is 0, means no expiration TTL int64 Prefix string Store CacheStore }
type CreateClause ¶ added in v1.0.0
func (CreateClause) Build ¶ added in v1.0.0
func (v CreateClause) Build(clause.Builder)
func (CreateClause) MergeClause ¶ added in v1.0.0
func (v CreateClause) MergeClause(*clause.Clause)
func (CreateClause) ModifyStatement ¶ added in v1.0.0
func (v CreateClause) ModifyStatement(stmt *gorm.Statement)
func (CreateClause) Name ¶ added in v1.0.0
func (v CreateClause) Name() string
type CurdParams ¶
type CurdParams struct { TableName string `json:"table_name,omitempty"` Values util.Map `json:"values,omitempty"` Where string `json:"where,omitempty"` Model interface{} `json:"-"` BeforeCall func(bean interface{}) Check func(bean interface{}) (err error) CheckBeforeUpdate func(oldVal, newVal interface{}) (err error) }
func (*CurdParams) AddUserIDCondition ¶
func (c *CurdParams) AddUserIDCondition(bean interface{}, userID uint64)
func (*CurdParams) AddWhereCondition ¶
func (c *CurdParams) AddWhereCondition(where string)
AddWhereCondition ... 添加where条件
type DBOption ¶
type DBOption struct { Type string `json:"type"` Host string `json:"host"` Port string `json:"port"` User string `json:"user"` Pwd string `json:"pwd"` DB string `json:"db"` SkipCache bool `json:"skip_cache"` CacheType string `json:"cache_type"` Logger logger.Interface `json:"-"` MaxIdleConns int `json:"max_idle_conns"` MaxOpenConns int `json:"max_open_conns"` MaxLifetimeSeconds int64 `json:"max_lifetime_seconds"` MaxIdleTimeSeconds int64 `json:"max_idle_time_seconds"` SkipCreateDB bool `json:"skipCreateDb,omitempty"` }
type FindByID ¶
type FindByID struct { TableName string `json:"table_name,omitempty"` ID uint64 `json:"id,omitempty"` Condition string `json:"condition,omitempty"` Dest interface{} `json:"-"` }
func (*FindByID) AppendEqCondition ¶ added in v0.0.5
AppendEqCondition ...
type FindParams ¶
type FindParams struct { Table string `json:"table,omitempty"` Condition string `json:"condition,omitempty"` Order string `json:"order,omitempty"` PageIndex int `json:"page_index,omitempty"` PageSize int `json:"page_size,omitempty"` Dest interface{} `json:"-"` }
func (*FindParams) AppendEqCondition ¶
func (f *FindParams) AppendEqCondition(str string)
AppendEqCondition ...
func (*FindParams) FindResultWithModel ¶
func (f *FindParams) FindResultWithModel(tx *gorm.DB) (result *FindResult, err error)
FindResultWithModel get data
type FindResult ¶
type FindResult struct { // Data Data interface{} `json:"data,omitempty"` // Pagination Pagination *Pagination `json:"pagination,omitempty"` // Extra Extra interface{} `json:"extra,omitempty"` }
type FreeStore ¶ added in v1.0.0
type FreeStore struct {
// contains filtered or unexported fields
}
func GetFreeCacheStore ¶ added in v1.0.0
func GetFreeCacheStore() *FreeStore
func NewFreeCacheStore ¶ added in v1.0.0
func NewFreeCacheStore() *FreeStore
func (*FreeStore) DropPrefix ¶ added in v1.0.0
type GormDB ¶
func (*GormDB) CheckDBNil ¶
func (*GormDB) GetFindModel ¶
GetFindModel ...
func (*GormDB) ModelByTableName ¶
ModelByTableName ...
func (*GormDB) ModelTableName ¶
ModelTableName ...
func (*GormDB) ViewModels ¶
type ImplResultAfterFind ¶
type ItfModelInitializer ¶
type Pagination ¶
type PluginCacheStat ¶
type RedisOptions ¶
type RedisStore ¶ added in v1.0.0
type RedisStore struct {
// contains filtered or unexported fields
}
func GetRedisStore ¶
func GetRedisStore(c *redis.Client, opts ...*RedisStoreOption) *RedisStore
func NewRedisStore ¶ added in v1.0.0
func NewRedisStore(c *redis.Client, opts ...*RedisStoreOption) *RedisStore
func (*RedisStore) ClearAll ¶ added in v1.0.0
func (r *RedisStore) ClearAll()
func (*RedisStore) Del ¶ added in v1.0.0
func (r *RedisStore) Del(key string)
func (*RedisStore) DropPrefix ¶ added in v1.0.0
func (r *RedisStore) DropPrefix(prefix ...string)
func (*RedisStore) Get ¶ added in v1.0.0
func (r *RedisStore) Get(key string) (data []byte, ok bool)
func (*RedisStore) GetKeyFieldOrNot ¶ added in v1.0.0
func (r *RedisStore) GetKeyFieldOrNot(key string) (k, f string, y bool)
func (*RedisStore) ScanKeys ¶ added in v1.0.0
func (r *RedisStore) ScanKeys(matchParam string) []string
func (*RedisStore) Set ¶ added in v1.0.0
func (r *RedisStore) Set(key string, data []byte, ttl ...int64)
func (*RedisStore) StoreGC ¶ added in v1.0.0
func (r *RedisStore) StoreGC(prefix string)
type RedisStoreOption ¶ added in v1.0.0
type RedisStoreOption struct {
Separator string
}
type RedisV9 ¶
type RedisV9 struct {
// contains filtered or unexported fields
}
func (*RedisV9) Initialize ¶
func (r *RedisV9) Initialize(opt *RedisOptions) *RedisV9
func (*RedisV9) Opt ¶
func (r *RedisV9) Opt() *RedisOptions
type RedisValue ¶ added in v1.0.0
type RedisValue struct { Val util.RawMessage `json:"val"` ExpireAt int64 `json:"expire_at"` }
type UpdateClause ¶ added in v1.0.0
func (UpdateClause) Build ¶ added in v1.0.0
func (v UpdateClause) Build(clause.Builder)
func (UpdateClause) MergeClause ¶ added in v1.0.0
func (v UpdateClause) MergeClause(*clause.Clause)
func (UpdateClause) ModifyStatement ¶ added in v1.0.0
func (v UpdateClause) ModifyStatement(stmt *gorm.Statement)
func (UpdateClause) Name ¶ added in v1.0.0
func (v UpdateClause) Name() string
type Version ¶ added in v1.0.0
func (*Version) CreateClauses ¶ added in v1.0.0
func (*Version) MarshalJSON ¶ added in v1.0.0
func (*Version) UnmarshalJSON ¶ added in v1.0.0
func (*Version) UpdateClauses ¶ added in v1.0.0
Click to show internal directories.
Click to hide internal directories.