model

package
v6.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountDeviceByWhere

func CountDeviceByWhere(whereCond string, arg ...interface{}) (int64, error)

CountDeviceByWhere count Device data number from database by WHERE condition. NOTE:

Without cache layer.

func CountLogByWhere

func CountLogByWhere(whereCond string, arg ...interface{}) (int64, error)

CountLogByWhere count Log data number from database by WHERE condition. NOTE:

Without cache layer.

func CountUserByWhere

func CountUserByWhere(whereCond string, arg ...interface{}) (int64, error)

CountUserByWhere count User data number from database by WHERE condition. NOTE:

Without cache layer.

func DeleteDeviceByPrimary

func DeleteDeviceByPrimary(_uuid string, deleteHard bool, tx ...*sqlx.Tx) error

DeleteDeviceByPrimary delete a Device data in database by primary key. NOTE:

Primary key: 'uuid';
With cache layer.

func DeleteLogByPrimary

func DeleteLogByPrimary(_id int64, deleteHard bool, tx ...*sqlx.Tx) error

DeleteLogByPrimary delete a Log data in database by primary key. NOTE:

Primary key: 'id';
With cache layer.

func DeleteUserByName

func DeleteUserByName(_name string, deleteHard bool, tx ...*sqlx.Tx) error

DeleteUserByName delete a User data in database by 'name' unique key. NOTE:

With cache layer.

func DeleteUserByPrimary

func DeleteUserByPrimary(_id int64, deleteHard bool, tx ...*sqlx.Tx) error

DeleteUserByPrimary delete a User data in database by primary key. NOTE:

Primary key: 'id';
With cache layer.

func GetDeviceDB

func GetDeviceDB() *mysql.CacheableDB

GetDeviceDB returns the Device DB handler.

func GetLogDB

func GetLogDB() *mysql.CacheableDB

GetLogDB returns the Log DB handler.

func GetMetaByFields

func GetMetaByFields(_m *Meta, _fields ...string) (bool, error)

GetMetaByFields query a Meta data from database by WHERE field. NOTE:

With cache layer;
If @return error!=nil, means the database error.

func GetMetaDB

func GetMetaDB() *mongo.CacheableDB

GetMetaDB returns the Meta DB handler.

func GetMongoDB

func GetMongoDB() *mongo.DB

GetMongoDB returns the mongo DB handler.

func GetMysqlDB

func GetMysqlDB() *mysql.DB

GetMysqlDB returns the mysql DB handler.

func GetRedis

func GetRedis() *redis.Client

GetRedis returns the redis client.

func GetUserDB

func GetUserDB() *mysql.CacheableDB

GetUserDB returns the User DB handler.

func Init

func Init(mysqlConfig *mysql.Config, mongoConfig *mongo.Config, redisConfig *redis.Config, _cacheExpire time.Duration) error

Init initializes the model packet.

func InsertDevice

func InsertDevice(_d *Device, tx ...*sqlx.Tx) error

InsertDevice insert a Device data into database. NOTE:

Primary key: 'uuid';
Without cache layer.

func InsertLog

func InsertLog(_l *Log, tx ...*sqlx.Tx) (int64, error)

InsertLog insert a Log data into database. NOTE:

Primary key: 'id';
Without cache layer.

func InsertUser

func InsertUser(_u *User, tx ...*sqlx.Tx) (int64, error)

InsertUser insert a User data into database. NOTE:

Primary key: 'id';
Without cache layer.

func ToArgsDevice

func ToArgsDevice(_d *Device) *args.Device

ToArgsDevice converts to *args.Device type.

func ToArgsDeviceSlice

func ToArgsDeviceSlice(a []*Device) []*args.Device

ToArgsDeviceSlice converts to []*args.Device type.

func ToArgsLog

func ToArgsLog(_l *Log) *args.Log

ToArgsLog converts to *args.Log type.

func ToArgsLogSlice

func ToArgsLogSlice(a []*Log) []*args.Log

ToArgsLogSlice converts to []*args.Log type.

func ToArgsMeta

func ToArgsMeta(_m *Meta) *args.Meta

ToArgsMeta converts to *args.Meta type.

func ToArgsUser

func ToArgsUser(_u *User) *args.User

ToArgsUser converts to *args.User type.

func ToArgsUserSlice

func ToArgsUserSlice(a []*User) []*args.User

ToArgsUserSlice converts to []*args.User type.

func UpdateDeviceByPrimary

func UpdateDeviceByPrimary(_d *Device, _updateFields []string, tx ...*sqlx.Tx) error

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

func UpdateLogByPrimary(_l *Log, _updateFields []string, tx ...*sqlx.Tx) error

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

func UpdateUserByName(_u *User, _updateFields []string, tx ...*sqlx.Tx) error

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

func UpdateUserByPrimary(_u *User, _updateFields []string, tx ...*sqlx.Tx) error

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

func UpsertDevice(_d *Device, _updateFields []string, tx ...*sqlx.Tx) error

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

func UpsertLog(_l *Log, _updateFields []string, tx ...*sqlx.Tx) (int64, error)

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

func UpsertMeta(selector, updater mongo.M) error

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

func UpsertUser(_u *User, _updateFields []string, tx ...*sqlx.Tx) (int64, error)

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

type Device args.Device

Device comment...

func GetDeviceByPrimary

func GetDeviceByPrimary(_uuid string) (*Device, bool, error)

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

func GetDeviceByWhere(whereCond string, arg ...interface{}) (*Device, bool, error)

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

func SelectDeviceByWhere(whereCond string, arg ...interface{}) ([]*Device, error)

SelectDeviceByWhere query some Device data from database by WHERE condition. NOTE:

Without cache layer.

func ToDevice

func ToDevice(_d *args.Device) *Device

ToDevice converts to *Device type.

func ToDeviceSlice

func ToDeviceSlice(a []*args.Device) []*Device

ToDeviceSlice converts to []*Device type.

func (*Device) TableName

func (*Device) TableName() string

TableName implements 'github.com/xiaoenai/tp-micro/model'.Cacheable

type Log

type Log args.Log

Log comment...

func GetLogByPrimary

func GetLogByPrimary(_id int64) (*Log, bool, error)

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

func GetLogByWhere(whereCond string, arg ...interface{}) (*Log, bool, error)

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

func SelectLogByWhere(whereCond string, arg ...interface{}) ([]*Log, error)

SelectLogByWhere query some Log data from database by WHERE condition. NOTE:

Without cache layer.

func ToLog

func ToLog(_l *args.Log) *Log

ToLog converts to *Log type.

func ToLogSlice

func ToLogSlice(a []*args.Log) []*Log

ToLogSlice converts to []*Log type.

func (*Log) TableName

func (*Log) TableName() string

TableName implements 'github.com/xiaoenai/tp-micro/model'.Cacheable

type Meta

type Meta args.Meta

Meta comment...

func GetMetaByWhere

func GetMetaByWhere(query mongo.M) (*Meta, bool, error)

GetMetaByWhere query a Meta data from database by WHERE condition. NOTE:

Without cache layer;
If @return error!=nil, means the database error.

func ToMeta

func ToMeta(_m *args.Meta) *Meta

ToMeta converts to *Meta type.

func (*Meta) TableName

func (*Meta) TableName() string

TableName implements 'github.com/xiaoenai/tp-micro/model'.Cacheable

type User

type User args.User

User user info

func GetUserByName

func GetUserByName(_name string) (*User, bool, error)

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

func GetUserByPrimary(_id int64) (*User, bool, error)

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

func GetUserByWhere(whereCond string, arg ...interface{}) (*User, bool, error)

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

func SelectUserByWhere(whereCond string, arg ...interface{}) ([]*User, error)

SelectUserByWhere query some User data from database by WHERE condition. NOTE:

Without cache layer.

func ToUser

func ToUser(_u *args.User) *User

ToUser converts to *User type.

func ToUserSlice

func ToUserSlice(a []*args.User) []*User

ToUserSlice converts to []*User type.

func (*User) TableName

func (*User) TableName() string

TableName implements 'github.com/xiaoenai/tp-micro/model'.Cacheable

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL