Documentation ¶
Index ¶
- Constants
- Variables
- func GetStructFields(root reflect.Type) []string
- func SubStrs(a, b []string) []string
- func ToStringSlice(a interface{}) []string
- type CacheUtil
- type DDL
- func (s *DDL) AddFK(table, target interface{}, fk string)
- func (s *DDL) AddFKs(table interface{})
- func (s *DDL) AddForeignKey(table, fkey, target, targetCol string, onDelete, onUpdate FKAction)
- func (s *DDL) AddTables(tables ...interface{})
- func (s *DDL) GetSchema(obj interface{}) *schema.Schema
- func (s *DDL) GetSchemaByStructName(structName string) *schema.Schema
- func (s *DDL) MakeFKName(table, fkey, target, targetCol string) string
- func (s *DDL) MakeFKs()
- func (s *DDL) MatchTableName(structType reflect.Type, tableName string) bool
- func (s *DDL) ParseFKInfo(tag string) FKInfo
- func (s *DDL) Range(f func(structType reflect.Type, tableSchema *schema.Schema) bool)
- type FKAction
- type FKInfo
- type FullTableCache
- func (s *FullTableCache) All() (interface{}, error)
- func (s *FullTableCache) Create(valueRef interface{}) error
- func (s *FullTableCache) Delete(ids ...interface{}) error
- func (s *FullTableCache) Exist() (bool, error)
- func (s *FullTableCache) Get(id interface{}) (interface{}, error)
- func (s *FullTableCache) Load() error
- func (s *FullTableCache) Save(valueRef interface{}) error
- func (s *FullTableCache) Update(valueRef interface{}, fields ...string) error
- type JSONMarshaller
- type Marshaller
- type RedisGorm
- func (s *RedisGorm) GetDB() *gorm.DB
- func (s *RedisGorm) GetID(value interface{}) interface{}
- func (s *RedisGorm) GetIDField(value interface{}) string
- func (s *RedisGorm) GetRedis() *redis.Client
- func (s *RedisGorm) GetTTL() time.Duration
- func (s *RedisGorm) IsIDInteger() bool
- func (s *RedisGorm) SetMarshaller(marshaller Marshaller)
- func (s *RedisGorm) SetRedisCtx(redisCtx context.Context)
- type TableCache
- func (s *TableCache) AddIndex(index []string)
- func (s *TableCache) ClearCache(objs ...interface{}) error
- func (s *TableCache) ClearCacheWithMaps(objs ...map[string]interface{}) error
- func (s *TableCache) Create(valueRef interface{}) error
- func (s *TableCache) CreateMany(sliceRef interface{}) error
- func (s *TableCache) Delete(ids ...interface{}) error
- func (s *TableCache) DeleteStrs(ids []string) error
- func (s *TableCache) DeleteUint64s(ids []uint64) error
- func (s *TableCache) Get(id interface{}) (interface{}, error)
- func (s *TableCache) GetBy(index ...interface{}) (interface{}, error)
- func (s *TableCache) GetByMap(index map[string]interface{}) (interface{}, error)
- func (s *TableCache) GetMaxID() (uint64, error)
- func (s *TableCache) List(ids interface{}) (interface{}, error)
- func (s *TableCache) ListBy(index ...interface{}) (interface{}, error)
- func (s *TableCache) ListByMap(index map[string]interface{}) (interface{}, error)
- func (s *TableCache) Save(valueRef interface{}) error
- func (s *TableCache) Update(resultRef interface{}, fields ...string) error
Constants ¶
View Source
const NullStr = "null"
Variables ¶
View Source
var EmptyStruct = struct{}{}
Functions ¶
func GetStructFields ¶
func ToStringSlice ¶
func ToStringSlice(a interface{}) []string
Types ¶
type CacheUtil ¶
type CacheUtil struct{}
func (*CacheUtil) GetFieldValue ¶
Get field from
func (*CacheUtil) MakeKeyWithMap ¶
type DDL ¶
type DDL struct { DefaultOnDelete FKAction DefaultOnUpdate FKAction // contains filtered or unexported fields }
func (*DDL) AddForeignKey ¶
func (*DDL) GetSchemaByStructName ¶
func (*DDL) MakeFKName ¶
func (*DDL) MatchTableName ¶
func (*DDL) ParseFKInfo ¶
tag: eg. FK:User,CASCADE,CASCADE Table,on delete %s,on update %s
type FullTableCache ¶
type FullTableCache struct { *RedisGorm // contains filtered or unexported fields }
func NewFullTableCache ¶
func NewFullTableCache(redisGorm *RedisGorm, key string) *FullTableCache
func (*FullTableCache) All ¶
func (s *FullTableCache) All() (interface{}, error)
All return all record from cache. type is: *[]Table
func (*FullTableCache) Create ¶
func (s *FullTableCache) Create(valueRef interface{}) error
func (*FullTableCache) Delete ¶
func (s *FullTableCache) Delete(ids ...interface{}) error
Delete by ids
func (*FullTableCache) Exist ¶
func (s *FullTableCache) Exist() (bool, error)
func (*FullTableCache) Get ¶
func (s *FullTableCache) Get(id interface{}) (interface{}, error)
Get record by id, type is *Table
func (*FullTableCache) Load ¶
func (s *FullTableCache) Load() error
func (*FullTableCache) Save ¶
func (s *FullTableCache) Save(valueRef interface{}) error
func (*FullTableCache) Update ¶
func (s *FullTableCache) Update(valueRef interface{}, fields ...string) error
type JSONMarshaller ¶
type JSONMarshaller struct { }
func (*JSONMarshaller) Marshal ¶
func (s *JSONMarshaller) Marshal(value interface{}) (string, error)
func (*JSONMarshaller) Unmarshal ¶
func (s *JSONMarshaller) Unmarshal(valueRef interface{}, bs string) error
type Marshaller ¶
type RedisGorm ¶
type RedisGorm struct { FactorySingleRef func() interface{} FactoryListRef func() interface{} // contains filtered or unexported fields }
func NewRedisGorm ¶
func (*RedisGorm) GetIDField ¶
func (*RedisGorm) IsIDInteger ¶
func (*RedisGorm) SetMarshaller ¶
func (s *RedisGorm) SetMarshaller(marshaller Marshaller)
func (*RedisGorm) SetRedisCtx ¶
type TableCache ¶
func NewTableCache ¶
func NewTableCache(redisGorm *RedisGorm, structName string, indexes [][]string) *TableCache
func (*TableCache) AddIndex ¶
func (s *TableCache) AddIndex(index []string)
func (*TableCache) ClearCache ¶
func (s *TableCache) ClearCache(objs ...interface{}) error
func (*TableCache) ClearCacheWithMaps ¶
func (s *TableCache) ClearCacheWithMaps(objs ...map[string]interface{}) error
func (*TableCache) Create ¶
func (s *TableCache) Create(valueRef interface{}) error
func (*TableCache) CreateMany ¶
func (s *TableCache) CreateMany(sliceRef interface{}) error
func (*TableCache) Delete ¶
func (s *TableCache) Delete(ids ...interface{}) error
Delete by id , eg. Delete(1,2)
func (*TableCache) DeleteStrs ¶
func (s *TableCache) DeleteStrs(ids []string) error
func (*TableCache) DeleteUint64s ¶
func (s *TableCache) DeleteUint64s(ids []uint64) error
func (*TableCache) Get ¶
func (s *TableCache) Get(id interface{}) (interface{}, error)
func (*TableCache) GetBy ¶
func (s *TableCache) GetBy(index ...interface{}) (interface{}, error)
GetBy index ,index:eg. uid,1
func (*TableCache) GetByMap ¶
func (s *TableCache) GetByMap(index map[string]interface{}) (interface{}, error)
redis key eg. projectusers/pid/2/uid/1 -> id
func (*TableCache) GetMaxID ¶
func (s *TableCache) GetMaxID() (uint64, error)
func (*TableCache) List ¶
func (s *TableCache) List(ids interface{}) (interface{}, error)
func (*TableCache) ListBy ¶
func (s *TableCache) ListBy(index ...interface{}) (interface{}, error)
ListBy index ,index:eg. uid,1
func (*TableCache) ListByMap ¶
func (s *TableCache) ListByMap(index map[string]interface{}) (interface{}, error)
redis key eg. projectusers/pid/2/uid/1 -> [id1,id2]
func (*TableCache) Save ¶
func (s *TableCache) Save(valueRef interface{}) error
func (*TableCache) Update ¶
func (s *TableCache) Update(resultRef interface{}, fields ...string) error
Click to show internal directories.
Click to hide internal directories.