Documentation
¶
Overview ¶
* @Author: liziwei01 * @Date: 2022-03-04 15:43:21 * @LastEditors: liziwei01 * @LastEditTime: 2023-11-01 11:22:02 * @Description: file content
* @Author: liziwei01 * @Date: 2022-03-09 19:26:42 * @LastEditors: liziwei01 * @LastEditTime: 2023-11-01 11:21:57 * @Description: file content
* @Author: liziwei01 * @Date: 2022-03-09 19:26:04 * @LastEditors: liziwei01 * @LastEditTime: 2022-04-17 15:39:35 * @Description: file content
* @Author: liziwei01 * @Date: 2022-03-04 15:42:58 * @LastEditors: liziwei01 * @LastEditTime: 2022-03-21 21:51:50 * @Description: file content
Index ¶
- func ExecWithBuilder(ctx context.Context, client Client, builder Builder) (sql.Result, error)
- func Execraw(ctx context.Context, client Client, builder Builder) (sql.Result, error)
- func QueryWithBuilder(ctx context.Context, client Client, builder Builder, data interface{}) error
- type Builder
- type Client
- type Config
- type DeleteBuilder
- type InsertBuilder
- type RawBuilder
- type SelectBuilder
- type UpdateBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecWithBuilder ¶
Types ¶
type Client ¶
type Client interface { // Query 查询, 返回数据在data, 内有didi builder, 结构体使用tag `ddb` Query(ctx context.Context, tableName string, where map[string]interface{}, columns []string, data interface{}) error // Insert 内有didi builder, 结构体使用tag `ddb` Insert(ctx context.Context, tableName string, data []map[string]interface{}) (sql.Result, error) InsertIgnore(ctx context.Context, tableName string, data []map[string]interface{}) (sql.Result, error) InsertReplace(ctx context.Context, tableName string, data []map[string]interface{}) (sql.Result, error) InsertOnDuplicate(ctx context.Context, tableName string, data []map[string]interface{}, update map[string]interface{}) (sql.Result, error) Update(ctx context.Context, tableName string, where map[string]interface{}, update map[string]interface{}) (sql.Result, error) Delete(ctx context.Context, tableName string, where map[string]interface{}) (sql.Result, error) // ExecRaw 拼接的原生sql语句 ExecRaw(ctx context.Context, sql string, args ...interface{}) (sql.Result, error) // contains filtered or unexported methods }
func GetClient ¶
*
- @description:
- @param {context.Context} ctx
- @param {string} serviceName
- @return {*}
func NewDefault ¶
func NewDefault() Client
type Config ¶
type Config struct { // Service的名字, 必选 Name string // 各种自定义的参数, 全部非必选 // 写数据超时 WriteTimeOut int // 读数据超时 ReadTimeOut int // 请求失败后的重试次数: 总请求次数 = Retry + 1 Retry int // 资源定位: 手动配置 - 使用IP、端口 Resource struct { Manual struct { Host string Port int } } MySQL struct { Username string Password string DBName string DBDriver string Charset string Collation string Timeout int SQLLogLen int } }
Config 配置
type DeleteBuilder ¶
type DeleteBuilder struct {
// contains filtered or unexported fields
}
func NewDeleteBuilder ¶
func NewDeleteBuilder(table string, where map[string]interface{}) *DeleteBuilder
func (*DeleteBuilder) CompileContext ¶
type InsertBuilder ¶
type InsertBuilder struct {
// contains filtered or unexported fields
}
InsertBuilder 默认的select sql builder
func NewInsertBuilder ¶
func NewInsertBuilder(table string, data []map[string]interface{}, typ int, update ...map[string]interface{}) *InsertBuilder
func (*InsertBuilder) CompileContext ¶
type RawBuilder ¶
type RawBuilder struct {
// contains filtered or unexported fields
}
func NewRawBuilder ¶
func NewRawBuilder(sql string, args []interface{}) *RawBuilder
func (*RawBuilder) CompileContext ¶
type SelectBuilder ¶
type SelectBuilder struct {
// contains filtered or unexported fields
}
SelectBuilder 默认的select sql builder
func NewSelectBuilder ¶
func NewSelectBuilder(table string, where map[string]interface{}, fields []string) *SelectBuilder
func (*SelectBuilder) CompileContext ¶
type UpdateBuilder ¶
type UpdateBuilder struct {
// contains filtered or unexported fields
}
func NewUpdateBuilder ¶
func NewUpdateBuilder(table string, where map[string]interface{}, update map[string]interface{}) *UpdateBuilder