Documentation ¶
Index ¶
- Constants
- func LoadTable(table Table, data map[string]interface{}) (bool, error)
- func Map2Table(table Table, data map[string]interface{}) (bool, error)
- func New(conf interface{}) drivers.DBDriver
- func Table2Map(table Table) map[string]interface{}
- type CTable
- type CacheTable
- type DataTable
- func (dt *DataTable) CountTable(table Table, params map[string]interface{}) (int64, error)
- func (dt *DataTable) DeleteTable(table Table) (bool, error)
- func (dt *DataTable) FetchTable(table Table, params map[string]interface{}) error
- func (dt *DataTable) FetchTables(tables interface{}, params map[string]interface{}) (interface{}, error)
- func (dt *DataTable) GetDriver() drivers.DBDriver
- func (dt *DataTable) InsertTable(table Table) (bool, error)
- func (dt *DataTable) IsConnected() bool
- func (dt *DataTable) StoreTable(table Table) (bool, error)
- func (dt *DataTable) SumTable(table Table, field string, params map[string]interface{}) (int64, error)
- func (dt *DataTable) UpdateTable(table Table) (bool, error)
- type Table
Constants ¶
const ( ConnectFailed = "database connect fail" BEFORE_INSERT = 0x01 BEFORE_DELETE = 0x02 BEFORE_UPDATE = 0x03 BEFORE_FETCH = 0x04 AFTER_INSERT = 0x05 AFTER_DELETE = 0x06 AFTER_UPDATE = 0x07 AFTER_FETCH = 0x08 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CTable ¶
type CTable interface { Table GetTimeOut() time.Duration GetCacheKey() string Where() map[string]interface{} }
CTable Table's cache version
type CacheTable ¶
CacheTable
func NewCacheTable ¶
func NewCacheTable(cache cache.Cache, dbConf config.Connect) *CacheTable
NewCacheTable instantiate
func (*CacheTable) Fetch ¶
func (ct *CacheTable) Fetch(table CTable) error
Fetch @feature fetch from cache, if not exist, get from db and update cache
func (*CacheTable) Save ¶
func (ct *CacheTable) Save(table CTable) error
Save @feature save to cache, and add request to queue
func (*CacheTable) Trash ¶
func (ct *CacheTable) Trash(table CTable) error
Trash @feature delete cache, and add request to queue
func (*CacheTable) Update ¶
func (ct *CacheTable) Update(table CTable) error
Update @feature update cache and add request to queue
type DataTable ¶
func NewDataTable ¶
func NewDataTable(conf interface{}) *DataTable
NewDataTable @conf two possible format:1. yaml config file path,2. map including all configuration
func (*DataTable) CountTable ¶
func (*DataTable) DeleteTable ¶
DeleteTable delete based on primary key
func (*DataTable) FetchTable ¶
FetchTable
@params table @params params, refer to utils/database/drivers/mysql.go
func (*DataTable) FetchTables ¶
func (dt *DataTable) FetchTables(tables interface{}, params map[string]interface{}) (interface{}, error)
FetchTables
@params tables, eg. tables := []table.PP @params params, refer to utils/database/drivers/mysql.go @return []Table
func (*DataTable) InsertTable ¶
InsertTable
@params table, must including data to insert @return bool success/failure,error
func (*DataTable) IsConnected ¶
func (*DataTable) StoreTable ¶
StoreTable
@notice if table has auto-incremental id primary key, action is update, otherwise action is insert @params table, must have data to store @return bool success/failure,error