Documentation ¶
Index ¶
- Variables
- func StructFields(root reflect.Type) []reflect.StructField
- type 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
- 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
- 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 JSONValueSerializer
- type 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
- 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
- type ValueSerializer
Constants ¶
This section is empty.
Variables ¶
View Source
var TableUpdateListener tableUpdateListener = tableUpdateListener{/* contains filtered or unexported fields */}
Functions ¶
func StructFields ¶
func StructFields(root reflect.Type) []reflect.StructField
Types ¶
type BaseDAO ¶
func NewBaseDAO ¶
func (*BaseDAO) DeleteMany ¶
func (*BaseDAO) GetByWithMap ¶
func (*BaseDAO) GetDBFieldName ¶
func (*BaseDAO) GetDBTableName ¶
func (*BaseDAO) HandleError ¶
func (*BaseDAO) InsertMany ¶
func (s *BaseDAO) InsertMany(valuesRef interface{})
func (*BaseDAO) ListByWithMap ¶
func (*BaseDAO) ListByWithOrder ¶
type CachedDAO ¶
type CachedDAO struct { *TableDAO Prefix string Redis *redis.Client Serializer ValueSerializer RedisisCtx context.Context TTL int // in minutes Indexes [][]string //eg. {{Uid} , {ProjectId, ModelId}} }
func NewCachedDAO ¶
func (*CachedDAO) CacheGetUint64 ¶
func (*CachedDAO) ClearCache ¶
func (s *CachedDAO) ClearCache(objs ...interface{})
ClearCache clear cache after insert and delete .eg ClearCache(User{1},User{2})
func (*CachedDAO) ClearCacheForTable ¶
func (s *CachedDAO) ClearCacheForTable()
func (*CachedDAO) ClearCacheWithMaps ¶
func (*CachedDAO) ClearCacheWithPrefix ¶
func (*CachedDAO) DeleteMany ¶
func (*CachedDAO) GetByWithMap ¶
redis key eg. projectusers/pid/2/uid/1 -> id
func (*CachedDAO) GetCacheMany ¶
return []string
func (*CachedDAO) GetIDValue ¶
func (*CachedDAO) InsertMany ¶
func (s *CachedDAO) InsertMany(valuesRef interface{})
func (*CachedDAO) ListByWithMap ¶
redis key eg. projectusers/pid/2/uid/1 -> [id1,id2]
func (*CachedDAO) MakeKey ¶
MakeKey MakeKey make cache key. eg. project_name/users/id/1. input like: k1,v1,k2,v2
func (*CachedDAO) MakeKeyByMap ¶
MakeKey make cache key. eg. project_name/users/id/1
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: Table , on delete , on update
type JSONValueSerializer ¶
type JSONValueSerializer struct { }
func (*JSONValueSerializer) Marshal ¶
func (s *JSONValueSerializer) Marshal(value interface{}) ([]byte, error)
func (*JSONValueSerializer) Unmarshal ¶
func (s *JSONValueSerializer) Unmarshal(data []byte, value interface{}) error
type SliceRef ¶
type SliceRef struct { // A slice pointer. Ref interface{} // contains filtered or unexported fields }
func NewSliceRef ¶
func NewSliceRef(ref interface{}) *SliceRef
func (*SliceRef) CreateInstance ¶
type StructRef ¶
type StructRef struct { // A struct pointer Ref interface{} // contains filtered or unexported fields }
func NewStructRef ¶
func NewStructRef(structRef interface{}) *StructRef
NewStructRef structRef should be a struct point
func (*StructRef) GetIgnoreCase ¶
func (*StructRef) GetIntoIgnoreCase ¶
func (*StructRef) GetRefIgnoreCase ¶
func (*StructRef) SetIgnoreCase ¶
type TableDAO ¶
type TableDAO struct { *BaseDAO Model interface{} // eg. &tables.User{} Table string // database table name of the model IDField string // ID }
func NewTableDAO ¶
func (*TableDAO) DeleteMany ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.