Documentation ¶
Index ¶
- func CountDeviceByWhere(whereCond string, arg ...interface{}) (int64, error)
- func CountLogByWhere(whereCond string, arg ...interface{}) (int64, error)
- func CountUserByWhere(whereCond string, arg ...interface{}) (int64, error)
- func DeleteDeviceByPrimary(_uuid string, deleteHard bool, tx ...*sqlx.Tx) error
- func DeleteLogByPrimary(_id int64, deleteHard bool, tx ...*sqlx.Tx) error
- func DeleteUserByName(_name string, deleteHard bool, tx ...*sqlx.Tx) error
- func DeleteUserByPrimary(_id int64, deleteHard bool, tx ...*sqlx.Tx) error
- func GetDeviceDB() *mysql.CacheableDB
- func GetLogDB() *mysql.CacheableDB
- func GetMetaByFields(_m *Meta, _fields ...string) (bool, error)
- func GetMetaDB() *mongo.CacheableDB
- 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 InsertDevice(_d *Device, tx ...*sqlx.Tx) error
- func InsertLog(_l *Log, tx ...*sqlx.Tx) (int64, error)
- func InsertUser(_u *User, tx ...*sqlx.Tx) (int64, error)
- func ToArgsDevice(_d *Device) *args.Device
- func ToArgsDeviceSlice(a []*Device) []*args.Device
- func ToArgsLog(_l *Log) *args.Log
- func ToArgsLogSlice(a []*Log) []*args.Log
- func ToArgsMeta(_m *Meta) *args.Meta
- func ToArgsUser(_u *User) *args.User
- func ToArgsUserSlice(a []*User) []*args.User
- func UpdateDeviceByPrimary(_d *Device, _updateFields []string, tx ...*sqlx.Tx) error
- func UpdateLogByPrimary(_l *Log, _updateFields []string, tx ...*sqlx.Tx) error
- func UpdateUserByName(_u *User, _updateFields []string, tx ...*sqlx.Tx) error
- func UpdateUserByPrimary(_u *User, _updateFields []string, tx ...*sqlx.Tx) error
- func UpsertDevice(_d *Device, _updateFields []string, tx ...*sqlx.Tx) error
- func UpsertLog(_l *Log, _updateFields []string, tx ...*sqlx.Tx) (int64, error)
- func UpsertMeta(selector, updater mongo.M) error
- func UpsertUser(_u *User, _updateFields []string, tx ...*sqlx.Tx) (int64, error)
- type Device
- func GetDeviceByPrimary(_uuid string) (*Device, bool, error)
- func GetDeviceByWhere(whereCond string, arg ...interface{}) (*Device, bool, error)
- func SelectDeviceByWhere(whereCond string, arg ...interface{}) ([]*Device, error)
- func ToDevice(_d *args.Device) *Device
- func ToDeviceSlice(a []*args.Device) []*Device
- type Log
- type Meta
- 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 CountDeviceByWhere ¶
CountDeviceByWhere count Device data number from database by WHERE condition. NOTE:
Without cache layer.
func CountLogByWhere ¶
CountLogByWhere count Log 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 DeleteDeviceByPrimary ¶
DeleteDeviceByPrimary delete a Device data in database by primary key. NOTE:
Primary key: 'uuid'; With cache layer.
func DeleteLogByPrimary ¶
DeleteLogByPrimary delete a Log data in database by primary key. NOTE:
Primary key: 'id'; With 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 GetMetaByFields ¶
GetMetaByFields query a Meta data from database by WHERE field. NOTE:
With cache layer; If @return error!=nil, means the database error.
func Init ¶
func Init(mysqlConfig *mysql.Config, mongoConfig *mongo.Config, redisConfig *redis.Config, _cacheExpire time.Duration) error
Init initializes the model packet.
func InsertDevice ¶
InsertDevice insert a Device data into database. NOTE:
Primary key: 'uuid'; Without cache layer.
func InsertLog ¶
InsertLog insert a Log data into database. NOTE:
Primary key: 'id'; Without cache layer.
func InsertUser ¶
InsertUser insert a User data into database. NOTE:
Primary key: 'id'; Without cache layer.
func ToArgsDevice ¶
ToArgsDevice converts to *args.Device type.
func ToArgsDeviceSlice ¶
ToArgsDeviceSlice converts to []*args.Device type.
func ToArgsLogSlice ¶
ToArgsLogSlice converts to []*args.Log type.
func ToArgsUserSlice ¶
ToArgsUserSlice converts to []*args.User type.
func UpdateDeviceByPrimary ¶
UpdateDeviceByPrimary update the Device data in database by primary key. NOTE:
Primary key: 'uuid'; 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 UpdateLogByPrimary ¶
UpdateLogByPrimary update the Log 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 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 UpsertDevice ¶
UpsertDevice insert or update the Device data by primary key. NOTE:
Primary key: 'uuid'; 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.
func UpsertLog ¶
UpsertLog insert or update the Log 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.
func UpsertMeta ¶
UpsertMeta insert or update the Meta data by selector and updater. NOTE:
With cache layer; Insert data if the primary key is specified; Update data based on _updateFields if no primary key is specified;
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 Device ¶
Device comment...
func GetDeviceByPrimary ¶
GetDeviceByPrimary query a Device data from database by primary key. NOTE:
Primary key: 'uuid'; With cache layer; If @return bool=false error=nil, means the data is not exist.
func GetDeviceByWhere ¶
GetDeviceByWhere query a Device data from database by WHERE condition. NOTE:
Without cache layer; If @return bool=false error=nil, means the data is not exist.
func SelectDeviceByWhere ¶
SelectDeviceByWhere query some Device data from database by WHERE condition. NOTE:
Without cache layer.
func ToDeviceSlice ¶
ToDeviceSlice converts to []*Device type.
type Log ¶
Log comment...
func GetLogByPrimary ¶
GetLogByPrimary query a Log 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 GetLogByWhere ¶
GetLogByWhere query a Log data from database by WHERE condition. NOTE:
Without cache layer; If @return bool=false error=nil, means the data is not exist.
func SelectLogByWhere ¶
SelectLogByWhere query some Log data from database by WHERE condition. NOTE:
Without cache layer.
type Meta ¶
Meta comment...
func GetMetaByWhere ¶
GetMetaByWhere query a Meta data from database by WHERE condition. NOTE:
Without cache layer; If @return error!=nil, means the database error.
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.