Documentation ¶
Index ¶
- func CreateUpdateSQLByNamed(tic TableIdxColumn, obj interface{}, ...) (string, map[string]interface{}, error)
- func CreateUpdateSQLByNamedAndSkipNil(tic TableIdxColumn, obj interface{}) (string, map[string]interface{}, error)
- func CreateUpdateSQLByNamedAndSkipNilAndSet(tic TableIdxColumn, obj interface{}) (string, map[string]interface{}, error)
- func DeleteOne(sqlx *sqlx.DB, sql string, params ...interface{}) error
- func IsNotFound(err error) bool
- func NewNowTime(t reflect.Type) interface{}
- func PickProxy(obj interface{}) interface{}
- func SelectColumns(obj interface{}) string
- func Struct2Map(obj interface{}) map[string]interface{}
- func UpdateAndSaveByIDWithNamed(sqlx *sqlx.DB, id *Index, fn func() (string, map[string]interface{}, error)) error
- func WithTx(ctx context.Context, db *sqlx.DB, fn func(tx *sqlx.Tx) error) error
- func WithTxV(ctx context.Context, db *sqlx.DB, fn func(*sqlx.Tx) (interface{}, error)) (interface{}, error)
- func WithTxVx(ctx context.Context, db *sqlx.DB, rr interface{}, ...) (interface{}, error)
- type Index
- type TableIdxColumn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateUpdateSQLByNamed ¶
func CreateUpdateSQLByNamed(tic TableIdxColumn, obj interface{}, fix func(t reflect.Type, n string, v interface{}, f *reflect.StructField) (interface{}, bool), set func(c string, p map[string]interface{}, v interface{}, f *reflect.StructField) (string, bool), ) (string, map[string]interface{}, error)
CreateUpdateSQLByNamed create update sql by named
func CreateUpdateSQLByNamedAndSkipNil ¶
func CreateUpdateSQLByNamedAndSkipNil(tic TableIdxColumn, obj interface{}) (string, map[string]interface{}, error)
CreateUpdateSQLByNamedAndSkipNil create update sql by named 忽略空字段, 空字段不进行更新, 如果需要前置更新空字段, 直接使用 CreateUpdateSQLByNamed
func CreateUpdateSQLByNamedAndSkipNilAndSet ¶
func CreateUpdateSQLByNamedAndSkipNilAndSet(tic TableIdxColumn, obj interface{}) (string, map[string]interface{}, error)
CreateUpdateSQLByNamedAndSkipNilAndSet create update sql by named 会处理 "set" 标签的内容 , 比如 `set:"=cloumn + 1"`
func UpdateAndSaveByIDWithNamed ¶
func UpdateAndSaveByIDWithNamed(sqlx *sqlx.DB, id *Index, fn func() (string, map[string]interface{}, error)) error
UpdateAndSaveByIDWithNamed update
Types ¶
type TableIdxColumn ¶
type TableIdxColumn struct { Table string IDCol string // index column IDVal interface{} // index data Update sql.NullBool DB *sqlx.DB IDCols []string // index columns IDVals map[string]interface{} // index datas }
TableIdxColumn id 1.Column="" 或者 Column = "id", 如果ID > 0 update, 否则 create 2.Update直接决定 update 或者 create 3.DB = nil 或者 Table = nil, 为 create 4.
Click to show internal directories.
Click to hide internal directories.