Documentation ¶
Index ¶
- func BindDivideArgByFields(_d *DivideArg, _fields ...string) (bool, error)
- func BindDivideArgByWhere(_d *DivideArg, whereNamedCond string) (bool, error)
- func BindUserByFields(_u *User, _fields ...string) (bool, error)
- func BindUserByWhere(_u *User, whereNamedCond string) (bool, error)
- func CountDivideArgByWhere(whereCond string, arg ...interface{}) (int64, error)
- func CountUserByWhere(whereCond string, arg ...interface{}) (int64, error)
- func DeleteDivideArgByPrimary(id int64, tx ...*sqlx.Tx) error
- func DeleteUserByPrimary(id int64, tx ...*sqlx.Tx) error
- func GetDB() *mysql.DB
- func GetDivideArgDB() *mysql.CacheableDB
- func GetRedis() *redis.Client
- func GetUserDB() *mysql.CacheableDB
- func Init(dbConfig mysql.Config, redisConfig redis.Config) error
- func InsertDivideArg(_d *DivideArg, tx ...*sqlx.Tx) (int64, error)
- func InsertUser(_u *User, tx ...*sqlx.Tx) (int64, error)
- func UpdateDivideArgByPrimary(_d *DivideArg, _updateFields []string, tx ...*sqlx.Tx) error
- func UpdateUserByPrimary(_u *User, _updateFields []string, tx ...*sqlx.Tx) error
- func UpsertDivideArg(_d *DivideArg, _updateFields []string, tx ...*sqlx.Tx) (int64, error)
- func UpsertUser(_u *User, _updateFields []string, tx ...*sqlx.Tx) (int64, error)
- type DivideArg
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindDivideArgByFields ¶
BindDivideArgByFields query the DivideArg data from database by field keys, and bind it to _d. NOTE:
With cache layer; _fields' members should be snake format; Query by the primary key field if fields is empty; If @return bool=false error=nil, means the data is not exist.
func BindDivideArgByWhere ¶
BindDivideArgByWhere query the DivideArg data from database by WHERE condition(whereNamedCond), and bind it to _d. NOTE:
With cache layer; If @return bool=false error=nil, means the data is not exist; whereNamedCond e.g. 'id=:id AND created_at>1520000000'.
func BindUserByFields ¶
BindUserByFields query the User data from database by field keys, and bind it to _u. NOTE:
With cache layer; _fields' members should be snake format; Query by the primary key field if fields is empty; If @return bool=false error=nil, means the data is not exist.
func BindUserByWhere ¶
BindUserByWhere query the User data from database by WHERE condition(whereNamedCond), and bind it to _u. NOTE:
With cache layer; If @return bool=false error=nil, means the data is not exist; whereNamedCond e.g. 'id=:id AND created_at>1520000000'.
func CountDivideArgByWhere ¶
CountDivideArgByWhere count DivideArg data number from database by WHERE condition. NOTE:
Without cache layer.
func CountUserByWhere ¶
CountUserByWhere count User data number from database by WHERE condition. NOTE:
Without cache layer.
func DeleteDivideArgByPrimary ¶
DeleteDivideArgByPrimary delete a DivideArg data in database by primary key. NOTE:
With cache layer.
func DeleteUserByPrimary ¶
DeleteUserByPrimary delete a User data in database by primary key. NOTE:
With cache layer.
func GetDivideArgDB ¶
func GetDivideArgDB() *mysql.CacheableDB
GetDivideArgDB returns the DivideArg DB handler.
func InsertDivideArg ¶
InsertDivideArg insert a DivideArg data into database. NOTE:
Without cache layer.
func UpdateDivideArgByPrimary ¶
UpdateDivideArgByPrimary update the DivideArg data in database by primary key. NOTE:
With cache layer; _updateFields' members must be snake format; Automatic update updated_at field; Don't update the primary key and the created_at key; Update all fields except the primary key and the created_at key if _updateFields is empty.
func UpdateUserByPrimary ¶
UpdateUserByPrimary update the User data in database by primary key. NOTE:
With cache layer; _updateFields' members must be snake format; Automatic update updated_at field; Don't update the primary key and the created_at key; Update all fields except the primary key and the created_at key if _updateFields is empty.
func UpsertDivideArg ¶
UpsertDivideArg insert or update the DivideArg data by primary key. NOTE:
With cache layer; Insert data if the primary key is specified; Update data based on _updateFields if no primary key is specified; _updateFields' members must be snake format; Automatic update updated_at field; Don't update the primary key and the created_at key; Update all fields except the primary key and the created_at key if _updateFields is empty.
func UpsertUser ¶
UpsertUser insert or update the User data by primary key. NOTE:
With cache layer; Insert data if the primary key is specified; Update data based on _updateFields if no primary key is specified; _updateFields' members must be snake format; Automatic update updated_at field; Don't update the primary key and the created_at key; Update all fields except the primary key and the created_at key if _updateFields is empty.
Types ¶
type DivideArg ¶
type DivideArg struct { Id int64 `json:"id"` // dividend A float64 `json:"a"` // divisor B float64 `json:"b" param:"<range: 0.01:100000>"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` }
DivideArg divide api arg
func GetDivideArgByPrimary ¶
GetDivideArgByPrimary query a DivideArg data from database by primary key. NOTE:
With cache layer; If @return bool=false error=nil, means the data is not exist.
func GetDivideArgByWhere ¶
GetDivideArgByWhere query a DivideArg data from database by WHERE condition. NOTE:
Without cache layer; If @return bool=false error=nil, means the data is not exist.
func SelectDivideArgByWhere ¶
SelectDivideArgByWhere query some DivideArg data from database by WHERE condition. NOTE:
Without cache layer.
type User ¶
type User struct { Id int64 `json:"id"` Name string `json:"name"` Age int32 `json:"age"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` }
User user info
func GetUserByPrimary ¶
GetUserByPrimary query a User data from database by primary key. NOTE:
With cache layer; If @return bool=false error=nil, means the data is not exist.
func GetUserByWhere ¶
GetUserByWhere query a User data from database by WHERE condition. NOTE:
Without cache layer; If @return bool=false error=nil, means the data is not exist.
func SelectUserByWhere ¶
SelectUserByWhere query some User data from database by WHERE condition. NOTE:
Without cache layer.