improve function Increment/Decrement for package gdb
@@ -93,17 +93,19 @@ func (m *Model) Update(dataAndWhere ...interface{}) (result sql.Result, err erro
}
// Increment increments a column's value by a given amount.
-func (m *Model) Increment(column string, amount float64) (sql.Result, error) {
+// The parameter `amount` can be type of float or integer.
+func (m *Model) Increment(column string, amount interface{}) (sql.Result, error) {
return m.getModel().Data(column, &Counter{
Field: column,
- Value: amount,
+ Value: gconv.Float64(amount),
}).Update()
}
// Decrement decrements a column's value by a given amount.
-func (m *Model) Decrement(column string, amount float64) (sql.Result, error) {
+// The parameter `amount` can be type of float or integer.
+func (m *Model) Decrement(column string, amount interface{}) (sql.Result, error) {
return m.getModel().Data(column, &Counter{
Field: column,
- Value: -amount,
+ Value: -gconv.Float64(amount),
}).Update()
}
