Documentation ¶
Index ¶
- Variables
- func Delete(tableName string, where map[string]interface{}) (int64, error)
- func GetCount(tableName string, where map[string]interface{}) (int64, error)
- func GetMulti(tableName string, where map[string]interface{}, selectField []string, ...) error
- func GetOne(tableName string, where map[string]interface{}, selectField []string, ...) error
- func Init()
- func Insert(tableName string, data []map[string]interface{}) (int64, error)
- func InsertIgnore(tableName string, data []map[string]interface{}) (int64, error)
- func InsertReplace(tableName string, data []map[string]interface{}) (int64, error)
- func TxDelete(tx *sql.Tx, tableName string, where map[string]interface{}) (int64, error)
- func TxGetMulti(tx *sql.Tx, tableName string, where map[string]interface{}, ...) error
- func TxGetOne(tx *sql.Tx, tableName string, where map[string]interface{}, ...) error
- func TxInsert(tx *sql.Tx, tableName string, data []map[string]interface{}) (int64, error)
- func TxInsertIgnore(tx *sql.Tx, tableName string, data []map[string]interface{}) (int64, error)
- func TxInsertReplace(tx *sql.Tx, tableName string, data []map[string]interface{}) (int64, error)
- func TxUpdate(tx *sql.Tx, tableName string, where, data map[string]interface{}) (int64, error)
- func Update(tableName string, where, data map[string]interface{}) (int64, error)
- type DaoMysqlSchema
Constants ¶
This section is empty.
Variables ¶
var (
Db *sql.DB
)
基于gendry 管理的sql builder的连接
Functions ¶
func GetMulti ¶
func GetMulti(tableName string, where map[string]interface{}, selectField []string, results interface{}) error
根据条件获取多条数据 @param tableName string 查询的表名 @param where map[string]interface{} 查询条件 @param selectField []string 查询选择返回的字段 @param results interface{} 带表结构存储结果的指针数组,接收返回的数据,接收results应与table schema struct相对应
func GetOne ¶
func GetOne(tableName string, where map[string]interface{}, selectField []string, result DaoMysqlSchema) error
以下提供通用的几个curd方法,具体构建方式可查看本目录的README
根据条件获取单条数据 @param tableName string 查询的表名 @param where map[string]interface{} 查询条件 @param selectField []string 查询选择返回的字段 @param result DaoMysqlSchema 带表结构存储结果的指针,接收返回的数据,实现DaoMysqlSchema接口
func Insert ¶
插入数据 @param tableName string 表名 @param data []map[string]interface{} 插入数据
@return LastInsertId int64 返回最新的插入id
func InsertIgnore ¶
插入数据,已存在则忽略 @param tableName string 表名 @param data []map[string]interface{} 插入数据
@return LastInsertId int64 返回最新的插入id
func InsertReplace ¶
插入数据,已存在则替换 @param tableName string 表名 @param data []map[string]interface{} 插入数据
@return LastInsertId int64 返回最新的插入id
func TxGetMulti ¶
func TxGetMulti(tx *sql.Tx, tableName string, where map[string]interface{}, selectField []string, results []DaoMysqlSchema) error
根据条件获取多条数据 @param tableName string 查询的表名 @param where map[string]interface{} 查询条件 @param selectField []string 查询选择返回的字段 @param results []DaoMysqlSchema 带表结构存储结果的指针数组,接收返回的数据,实现DaoMysqlSchema接口
func TxGetOne ¶
func TxGetOne(tx *sql.Tx, tableName string, where map[string]interface{}, selectField []string, result DaoMysqlSchema) error
以下提供通用的几个基于事务的curd方法,具体构建方式可查看本目录的README
根据条件获取单条数据 @param tableName string 查询的表名 @param where map[string]interface{} 查询条件 @param selectField []string 查询选择返回的字段 @param result DaoMysqlSchema 带表结构存储结果的指针,接收返回的数据,实现DaoMysqlSchema接口
func TxInsert ¶
插入数据 @param tableName string 表名 @param data []map[string]interface{} 插入数据
@return LastInsertId int64 返回最新的插入id
func TxInsertIgnore ¶
插入数据,已存在则忽略 @param tableName string 表名 @param data []map[string]interface{} 插入数据
@return LastInsertId int64 返回最新的插入id
func TxInsertReplace ¶
插入数据,已存在则替换 @param tableName string 表名 @param data []map[string]interface{} 插入数据
@return LastInsertId int64 返回最新的插入id
Types ¶
type DaoMysqlSchema ¶
type DaoMysqlSchema interface {
TableName() string
}
sql builder 映射的表struct应该实现的接口,实现该结构可使用一些通用的curd方法