Documentation ¶
Index ¶
- func CountUserByWhere(whereCond string, arg ...interface{}) (int64, error)
- func DeleteUserByName(_name string, deleteHard bool, tx ...*sqlx.Tx) error
- func DeleteUserByPrimary(_id int64, deleteHard bool, tx ...*sqlx.Tx) error
- func GetMongoDB() *mongo.DB
- func GetMysqlDB() *mysql.DB
- func GetRedis() *redis.Client
- func GetUserDB() *mysql.CacheableDB
- func Init(mysqlConfig *mysql.Config, mongoConfig *mongo.Config, ...) error
- func InsertUser(_u *User, tx ...*sqlx.Tx) (int64, error)
- func ToArgsUser(_u *User) *args.User
- func ToArgsUserSlice(a []*User) []*args.User
- func UpdateUserByName(_u *User, _updateFields []string, tx ...*sqlx.Tx) error
- func UpdateUserByPrimary(_u *User, _updateFields []string, tx ...*sqlx.Tx) error
- func UpsertUser(_u *User, _updateFields []string, tx ...*sqlx.Tx) (int64, error)
- type User
- func GetUserByName(_name string) (*User, bool, error)
- func GetUserByPrimary(_id int64) (*User, bool, error)
- func GetUserByWhere(whereCond string, arg ...interface{}) (*User, bool, error)
- func SelectUserByWhere(whereCond string, arg ...interface{}) ([]*User, error)
- func ToUser(_u *args.User) *User
- func ToUserSlice(a []*args.User) []*User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountUserByWhere ¶
CountUserByWhere count User data number from database by WHERE condition. NOTE:
Without cache layer.
func DeleteUserByName ¶
DeleteUserByName delete a User data in database by 'name' unique key. NOTE:
With cache layer.
func DeleteUserByPrimary ¶
DeleteUserByPrimary delete a User data in database by primary key. NOTE:
Primary key: 'id'; With cache layer.
func Init ¶
func Init(mysqlConfig *mysql.Config, mongoConfig *mongo.Config, redisConfig *redis.Config, _cacheExpire time.Duration) error
Init initializes the model packet.
func InsertUser ¶
InsertUser insert a User data into database. NOTE:
Primary key: 'id'; Without cache layer.
func ToArgsUserSlice ¶
ToArgsUserSlice converts to []*args.User type.
func UpdateUserByName ¶
UpdateUserByName update the User data in database by 'name' unique key. NOTE:
With cache layer; _updateFields' members must be db field style (snake format); Automatic update 'updated_at' field; Don't update the primary keys, 'created_at' key and 'deleted_ts' key; Update all fields except the primary keys, 'name' unique key, 'created_at' key and 'deleted_ts' key, if _updateFields is empty.
func UpdateUserByPrimary ¶
UpdateUserByPrimary update the User data in database by primary key. NOTE:
Primary key: 'id'; With cache layer; _updateFields' members must be db field style (snake format); Automatic update 'updated_at' field; Don't update the primary keys, 'created_at' key and 'deleted_ts' key; Update all fields except the primary keys, 'created_at' key and 'deleted_ts' key, if _updateFields is empty.
func UpsertUser ¶
UpsertUser insert or update the User data by primary key. NOTE:
Primary key: 'id'; 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 db field style (snake format); Automatic update 'updated_at' field; Don't update the primary keys, 'created_at' key and 'deleted_ts' key; Update all fields except the primary keys, 'created_at' key and 'deleted_ts' key, if _updateFields is empty.
Types ¶
type User ¶
User user info
func GetUserByName ¶
GetUserByName query a User data from database by 'name' unique key. NOTE:
With cache layer; If @return bool=false error=nil, means the data is not exist.
func GetUserByPrimary ¶
GetUserByPrimary query a User data from database by primary key. NOTE:
Primary key: 'id'; 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.