Documentation ¶
Index ¶
- type DBDriver
- type MySQL
- func (my *MySQL) Count(tableName string, params map[string]interface{}) int64
- func (my *MySQL) Delete(tableName string, where map[string]interface{}) int64
- func (my *MySQL) FetchAll(tableName string, params map[string]interface{}) ([]map[string]interface{}, error)
- func (my *MySQL) FetchOne(tableName string, params map[string]interface{}) (map[string]interface{}, error)
- func (my *MySQL) Init(config *config.Connect) bool
- func (my *MySQL) Insert(tableName string, columns []string, data ...[]interface{}) (int64, int64)
- func (my *MySQL) IsConnected() bool
- func (my *MySQL) Sum(tableName string, field string, params map[string]interface{}) int64
- func (my *MySQL) Update(tableName string, data, where map[string]interface{}) int64
- type SQLite
- func (s *SQLite) Count(tableName string, params map[string]interface{}) int64
- func (s *SQLite) Delete(tableName string, where map[string]interface{}) int64
- func (s *SQLite) FetchAll(tableName string, params map[string]interface{}) ([]map[string]interface{}, error)
- func (s *SQLite) FetchOne(tableName string, params map[string]interface{}) (map[string]interface{}, error)
- func (s *SQLite) Init(config *config.Connect) bool
- func (s *SQLite) Insert(tableName string, columns []string, data ...[]interface{}) (int64, int64)
- func (s *SQLite) IsConnected() bool
- func (s *SQLite) Sum(tableName string, field string, params map[string]interface{}) int64
- func (s *SQLite) Update(tableName string, data, where map[string]interface{}) int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBDriver ¶
type DBDriver interface { Init(config *config.Connect) bool IsConnected() bool Insert(tableName string, columns []string, data ...[]interface{}) (int64, int64) Delete(tableName string, where map[string]interface{}) int64 Update(tableName string, data, where map[string]interface{}) int64 FetchAll(tableName string, params map[string]interface{}) ([]map[string]interface{}, error) FetchOne(tableName string, params map[string]interface{}) (map[string]interface{}, error) Count(tableName string, params map[string]interface{}) int64 Sum(tableName string, field string, params map[string]interface{}) int64 SetCacheEngine(cache cache.Cache) IsCacheEngineOK() bool GetDB() *sql.DB }
DBDriver interface
type MySQL ¶
MySQL
func (*MySQL) Delete ¶
Delete
@params tableName @params where, format:
map[string]interface{}{"id = ?": 1} map[string]interface{}{"id = ? AND domain = ?": []interface{}{1, "exsample.com"}}
func (*MySQL) FetchAll ¶
func (my *MySQL) FetchAll(tableName string, params map[string]interface{}) ([]map[string]interface{}, error)
FetchAll
@params tableName @params params, including:where, group by, having, order by, limit, offset eg.
map[string]interface{}{ "columns": "id, domain, url", "where": map[string]interface{}{ "domain = ? AND url = ?": []interface{}{"www.exsample.com", "/mail"}, which is equally as "domain = ?": "www.exsample.com", "url = ?": "/mail", }, "groupBy": "id", "orderBy": "id DESC", "limit": 1, "offset": 1, }
func (*MySQL) FetchOne ¶
func (my *MySQL) FetchOne(tableName string, params map[string]interface{}) (map[string]interface{}, error)
FetchOne
refer to FetchAll
func (*MySQL) Insert ¶
Insert
@params tableName @params columns. format: []string{"domain", "url"}, attention: when columns are empty, it means all columns @params data... format: []interface{}{ "exsample.com", "/mail" }, same order of columns
type SQLite ¶
func (*SQLite) Delete ¶
Delete
@params tableName @params where, format:
map[string]interface{}{"id = ?": 1} map[string]interface{}{"id = ? AND domain = ?": []interface{}{1, "exsample.com"}}
func (*SQLite) FetchAll ¶
func (s *SQLite) FetchAll(tableName string, params map[string]interface{}) ([]map[string]interface{}, error)
FetchAll
@params tableName @params params, including:where, group by, having, order by, limit, offset eg.
map[string]interface{}{ "columns": "id, domain, url", "where": map[string]interface{}{ "domain = ? AND url = ?": []interface{}{"www.exsample.com", "/mail"}, which is equally as "domain = ?": "www.exsample.com", "url = ?": "/mail", }, "groupBy": "id", "orderBy": "id DESC", "limit": 1, "offset": 1, }
func (*SQLite) FetchOne ¶
func (s *SQLite) FetchOne(tableName string, params map[string]interface{}) (map[string]interface{}, error)
FetchOne
refer to FetchAll
func (*SQLite) Insert ¶
Insert
@params tableName @params columns. format: []string{"domain", "url"}, attention: when columns are empty, it means all columns @params data... format: []interface{}{ "exsample.com", "/mail" }, same order of columns