orm add atomic set value
This commit is contained in:
@@ -4,6 +4,36 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type colValue struct {
|
||||
value int64
|
||||
opt operator
|
||||
}
|
||||
|
||||
type operator int
|
||||
|
||||
const (
|
||||
Col_Add operator = iota
|
||||
Col_Minus
|
||||
Col_Multiply
|
||||
Col_Except
|
||||
)
|
||||
|
||||
func ColValue(opt operator, value interface{}) interface{} {
|
||||
switch opt {
|
||||
case Col_Add, Col_Minus, Col_Multiply, Col_Except:
|
||||
default:
|
||||
panic(fmt.Errorf("orm.ColValue wrong operator"))
|
||||
}
|
||||
v, err := StrTo(ToStr(value)).Int64()
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("orm.ColValue doesn't support non string/numeric type, %s", err))
|
||||
}
|
||||
var val colValue
|
||||
val.value = v
|
||||
val.opt = opt
|
||||
return val
|
||||
}
|
||||
|
||||
type querySet struct {
|
||||
mi *modelInfo
|
||||
cond *Condition
|
||||
|
||||
Reference in New Issue
Block a user