Versions in this module Expand all Collapse all v0 v0.0.2 Sep 21, 2021 v0.0.1 Sep 16, 2021 Changes in this version + var TableUpdateListener tableUpdateListener = tableUpdateListener + func StructFields(root reflect.Type) []reflect.StructField + type BaseDAO struct + DB *gorm.DB + TableMaxIdSql string + func NewBaseDAO(db *gorm.DB) *BaseDAO + func (s *BaseDAO) All(resultRef interface{}) + func (s *BaseDAO) Begin(opts ...*sql.TxOptions) *BaseDAO + func (s *BaseDAO) Count(sql string, values ...interface{}) uint64 + func (s *BaseDAO) Delete(resultRef interface{}, id uint64) + func (s *BaseDAO) DeleteMany(valueRef interface{}, ids []uint64) + func (s *BaseDAO) Get(resultRef interface{}, id uint64) + func (s *BaseDAO) GetBy(resultRef interface{}, kvs ...interface{}) + func (s *BaseDAO) GetByWithMap(resultRef interface{}, kvs map[string]interface{}) + func (s *BaseDAO) GetDBFieldName(structFieldName string) string + func (s *BaseDAO) GetDBTableName(table string) string + func (s *BaseDAO) GetMaxID(dbTableName string, dbIdField ...string) uint64 + func (s *BaseDAO) HandleError(err error) + func (s *BaseDAO) Insert(valueRef interface{}) + func (s *BaseDAO) InsertMany(valuesRef interface{}) + func (s *BaseDAO) List(resultRef interface{}, ids []uint64) + func (s *BaseDAO) ListBy(resultRef interface{}, kvs ...interface{}) + func (s *BaseDAO) ListByWithMap(resultRef interface{}, orderBy string, kvs map[string]interface{}) + func (s *BaseDAO) ListByWithOrder(resultRef interface{}, orderBy string, kvs ...interface{}) + func (s *BaseDAO) Put(resultRef interface{}, fields ...string) + func (s *BaseDAO) Save(valueRef interface{}) + func (s *BaseDAO) Select(result interface{}, sql string, values ...interface{}) + func (s *BaseDAO) Transaction(fn func(db *BaseDAO) error, opts ...*sql.TxOptions) error + type CachedDAO struct + Indexes [][]string + Prefix string + Redis *redis.Client + RedisisCtx context.Context + Serializer ValueSerializer + TTL int + func NewCachedDAO(db *gorm.DB, model interface{}, table string, idField string, ...) *CachedDAO + func (s *CachedDAO) AddIndex(index ...string) *CachedDAO + func (s *CachedDAO) CacheGet(key string, valueRef interface{}) bool + func (s *CachedDAO) CacheGetUint64(key string) uint64 + func (s *CachedDAO) CacheSet(key string, value interface{}) + func (s *CachedDAO) ClearCache(objs ...interface{}) + func (s *CachedDAO) ClearCacheForTable() + func (s *CachedDAO) ClearCacheWithMaps(objs ...map[string]interface{}) + func (s *CachedDAO) ClearCacheWithPrefix(prefix string) + func (s *CachedDAO) Delete(id uint64) + func (s *CachedDAO) DeleteMany(ids []uint64) + func (s *CachedDAO) Get(valueRef interface{}, id uint64) + func (s *CachedDAO) GetBy(valueRef interface{}, indexes ...interface{}) + func (s *CachedDAO) GetByWithMap(valueRef interface{}, indexes map[string]interface{}) + func (s *CachedDAO) GetCacheMany(keys []string) []interface{} + func (s *CachedDAO) GetIDValue(valueRef interface{}) uint64 + func (s *CachedDAO) GetKeyID(v interface{}) string + func (s *CachedDAO) GetKeyMax() string + func (s *CachedDAO) GetMaxID() uint64 + func (s *CachedDAO) Insert(valueRef interface{}) + func (s *CachedDAO) InsertMany(valuesRef interface{}) + func (s *CachedDAO) List(valueRef interface{}, ids []uint64) + func (s *CachedDAO) ListBy(valueRef interface{}, indexes ...interface{}) + func (s *CachedDAO) ListByWithMap(valueRef interface{}, indexes map[string]interface{}) + func (s *CachedDAO) MakeKey(indexValues ...interface{}) string + func (s *CachedDAO) MakeKeyByMap(indexValues map[string]interface{}) string + func (s *CachedDAO) Put(resultRef interface{}, fields ...string) + func (s *CachedDAO) Save(valueRef interface{}) + type DDL struct + DefaultOnDelete FKAction + DefaultOnUpdate FKAction + func NewDDL(db *gorm.DB) *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 string + const FKCascade + const FKNoAction + const FKRestrict + const FKSetNull + type FKInfo struct + OnDelete FKAction + OnUpdate FKAction + StructName string + type JSONValueSerializer struct + func (s *JSONValueSerializer) Marshal(value interface{}) ([]byte, error) + func (s *JSONValueSerializer) Unmarshal(data []byte, value interface{}) error + type SliceRef struct + Ref interface{} + func NewSliceRef(ref interface{}) *SliceRef + func (s *SliceRef) Append(value interface{}) *SliceRef + func (s *SliceRef) CreateInstance(len, cap int) interface{} + func (s *SliceRef) Get(i int) interface{} + func (s *SliceRef) GetInto(i int, valueRef interface{}) + func (s *SliceRef) GetRef(i int) interface{} + func (s *SliceRef) Len() int + func (s *SliceRef) New(len, cap int) *SliceRef + func (s *SliceRef) Set(i int, value interface{}) + type StructRef struct + Ref interface{} + func NewStructRef(structRef interface{}) *StructRef + func (s *StructRef) Create() *StructRef + func (s *StructRef) Get(name string) interface{} + func (s *StructRef) GetIgnoreCase(name string) interface{} + func (s *StructRef) GetInto(name string, valueRef interface{}) + func (s *StructRef) GetIntoIgnoreCase(name string, valueRef interface{}) + func (s *StructRef) GetRef(name string) interface{} + func (s *StructRef) GetRefIgnoreCase(name string) interface{} + func (s *StructRef) Map() map[string]interface{} + func (s *StructRef) Names() []string + func (s *StructRef) NewSlice(len, cap int) interface{} + func (s *StructRef) Set(name string, value interface{}) *StructRef + func (s *StructRef) SetIgnoreCase(name string, value interface{}) *StructRef + type TableDAO struct + IDField string + Model interface{} + Table string + func NewTableDAO(db *gorm.DB, model interface{}, table string, idField string) *TableDAO + func (s *TableDAO) Delete(id uint64) + func (s *TableDAO) DeleteMany(ids []uint64) + func (s *TableDAO) GetMaxID() uint64 + type ValueSerializer interface + Marshal func(value interface{}) ([]byte, error) + Unmarshal func(data []byte, value interface{}) error