Documentation ¶
Index ¶
- func DeleteTx(ctx context.Context, tx *sqlx.Tx, table string, id ...int64) error
- func DeleteWhereTx(ctx context.Context, tx *sqlx.Tx, table string, where string, ...) error
- func InsertTx(ctx context.Context, tx *sqlx.Tx, table string, data map[string]interface{}) (int64, error)
- func IsNotFound(err error) bool
- func UpdateTx(ctx context.Context, tx *sqlx.Tx, table string, id int64, ...) error
- func UpdateWhereTx(ctx context.Context, tx *sqlx.Tx, table string, data map[string]interface{}, ...) error
- type MySQL
- func (m *MySQL) Connect(ctx context.Context) (*sqlx.DB, error)
- func (m *MySQL) Delete(ctx context.Context, table string, id ...int64) error
- func (m *MySQL) DeleteWhere(ctx context.Context, table string, where string, args ...interface{}) error
- func (m *MySQL) Exec(ctx context.Context, statement string, args ...interface{}) (sql.Result, error)
- func (m *MySQL) Get(ctx context.Context, data interface{}, query string, args ...interface{}) error
- func (m *MySQL) Gets(ctx context.Context, data interface{}, query string, args ...interface{}) error
- func (m *MySQL) Insert(ctx context.Context, table string, data map[string]interface{}) (int64, error)
- func (m *MySQL) Tx(ctx context.Context, f func(ctx context.Context, tx *sqlx.Tx) error) error
- func (m *MySQL) Update(ctx context.Context, table string, id int64, data map[string]interface{}) error
- func (m *MySQL) UpdateWhere(ctx context.Context, table string, data map[string]interface{}, where string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteWhereTx ¶
func DeleteWhereTx(ctx context.Context, tx *sqlx.Tx, table string, where string, args ...interface{}) error
DeleteWhereTx 通过 where 条件来删除数据
func InsertTx ¶
func InsertTx(ctx context.Context, tx *sqlx.Tx, table string, data map[string]interface{}) (int64, error)
InsertTx 使用事务向 MySQL 中插入一条数据
Types ¶
type MySQL ¶
type MySQL struct {
// contains filtered or unexported fields
}
MySQL 是使用 mysql 对 Storage 接口的实现
func (*MySQL) DeleteWhere ¶
func (m *MySQL) DeleteWhere(ctx context.Context, table string, where string, args ...interface{}) error
DeleteWhere 通过 where 条件来删除数据
func (*MySQL) Exec ¶
func (m *MySQL) Exec(ctx context.Context, statement string, args ...interface{}) (sql.Result, error)
Exec 执行语句
func (*MySQL) Gets ¶
func (m *MySQL) Gets(ctx context.Context, data interface{}, query string, args ...interface{}) error
Gets 查询一组数据, 要求 data 是一个切片结构
func (*MySQL) Insert ¶
func (m *MySQL) Insert(ctx context.Context, table string, data map[string]interface{}) (int64, error)
Insert 向 MySQL 中插入一条数据
Click to show internal directories.
Click to hide internal directories.